This repository contains an end-to-end Cypress test suite for the Demoblaze e-commerce web application. The automated coverage focuses on the essential user journey for a new customer: creating an account, logging in, and purchasing a laptop.
The goal is to build a reliable regression suite for the most important flows of the online store, with a strong emphasis on the following scenario:
- Create a new user account
- Log in with valid credentials
- Browse laptops
- Select a laptop product
- Add it to the cart
- Place an order and confirm the purchase
This project is designed to support a fast launch of automated coverage with Cypress, using clean page object patterns and reusable test logic.
- Cypress
- TypeScript
- Faker.js for generating dynamic test data
- Page Object Model (POM) structure
.
├── cypress/
│ ├── e2e/
│ │ ├── login.cy.ts
│ │ ├── purchase.cy.ts
│ │ └── signup.cy.ts
│ ├── fixtures/
│ │ └── example.json
│ ├── pages/
│ │ ├── cartPage.ts
│ │ ├── homePage.ts
│ │ ├── loginPage.ts
│ │ ├── orderModalPage.ts
│ │ ├── productDetailsPage.ts
│ │ ├── productListPage.ts
│ │ └── signupPage.ts
│ └── support/
│ ├── commands.ts
│ └── e2e.ts
├── cypress.config.ts
├── cypress.env.json
├── package.json
├── tsconfig.json
├── README.md
└── package-lock.json- Opens the Demoblaze homepage
- Navigates to the signup form
- Creates a random new user account
- Validates confirmation message
- Visits the homepage
- Opens the login form
- Login with registered user's credentials
- Validates successful login
- Verifies invalid input handling for:
- non-existent user
- wrong password
- empty credentials
- Logs in as a valid user
- Opens the Laptops category
- Selects the laptop(MacBook Pro) product
- Adds the laptop to cart
- Verifies the cart contains the expected item and the correct line-item price
- Verifies the cart total matches the selected product price
- Places an order and verifies the checkout modal is visible
- Fills in billing details
- Confirms the purchase request completes and the receipt contains the amount, card number, and customer name
The essential flows were selected based on business risk and customer impact(risk based testing). In an e-commerce application, the most critical activities are creating an account, signing in, selecting a product, and completing checkout. If these fail, the customer cannot complete a purchase, so they were prioritized first.
The tests were designed to cover the primary happy path and the most important validation scenarios:
- Sign-up: verifies that a new customer can create an account successfully, which is a prerequisite for the purchase flow.
- Login: covers both valid and invalid authentication attempts, ensuring the app correctly handles both successful access and common user errors.
- Purchase flow: validates that a laptop can be selected, added to the cart, and ordered through the checkout process without interruption.
This approach follows a risk-based testing strategy: the suite focuses on the core user journey and the highest-risk validation points, while keeping the tests simple, readable, and maintainable. The Page Object Model was used to separate test logic from UI selectors so the suite is easier to extend when additional scenarios are needed.
The test design also emphasizes real user behavior rather than implementation details. Each test navigates through the app as a customer would, validates visible UI states, checks business-critical totals and receipt data, and waits for the corresponding API request before moving to the next state. Alert messages are asserted where the application exposes feedback through browser alerts. This makes failures easier to localize and reduces timing-related flakiness.
The test suite is configured in cypress.config.ts with the following defaults:
- Base URL:
https://www.demoblaze.com - Default timeout:
8000ms - Spec pattern:
cypress/e2e/**/*.cy.ts - Viewport:
1920 x 1080
The suite expects a registered Demoblaze user to exist in cypress.env.json before running the login and purchase flows. Use your own valid test account credentials there instead of committing real account details to the repository.
{
"username": "ENTER_YOUR_REGISTERED_USERNAME",
"password": "ENTER_YOUR_REGISTERED_PASSWORD"
}Before running the tests, install the required dependencies:
- Node.js (LTS version recommended)
- npm(version >= 11.0)
- git(version >= 2.55.0)
Clone the project onto your machine by the following commands and then install the node package dependencies:
git clone https://github.com/batabek/demoblaze_task.git
cd demoblaze_task
npm installAfter the repository is available locally, you can run the Cypress tests with the commands below.
Tests can be run within Cypress Launchpad or directly with headless mode via npm scripts
Enter the following command to run all the E2E tests within the Cypress Launchpad
npm run cy:open:e2eAfter it is loaded, select an available browser and then click on Start E2E Testing in [Selected Browser Name]. All the E2E spec files are dislayed and you can click on one of them to start running it. After the execution, you can see the detailed executed test steps from the command log in the Test Runner.
To select a specific browser for running tests, you can use the following npm script conventions directly.
npm run cy:run:chrome // For running tests in Chrome browser
npm run cy:run:firefox // For running tests in Firefox browser
npm run cy:run:edge // For running tests in Edge browserNote that the selected browser must be installed on your system prior to executing the tests.
- This project follows the Page Object Model to keep tests readable and maintainable.
- Alerts are used throughout the app for validation, so Cypress listeners are used to assert the expected browser messages.
- The suite uses generated random values where possible to reduce test dependence on fixed data.
- The current focus is on critical user journeys rather than a broad coverage set, which matches the requested tight-deadline QA objective.
Some possible next steps for the project include:
- Adding negative tests for purchase validation
- Covering additional product categories
- Adding negative tests for checkout validation and cart state changes
- Adding reporting and screenshots for failed tests