This project contains end-to-end tests for a mock e-commerce application using Cypress with TypeScript and the Page Object Model pattern.
The tests automate two main flows:
- Successful order flow - a user who can complete a purchase successfully
- Failed order flow - a user whose payments are always declined
cypress/
├── e2e/ # Test files
│ ├── successful-order-flow.cy.ts
│ └── failed-order-flow.cy.ts
├── fixtures/ # Test data
│ ├── users.json
│ ├── products.json
│ └── payment.json
├── pages/ # Page Objects
│ ├── LoginPage.ts
│ ├── ProductsPage.ts
│ ├── CartPage.ts
│ └── CheckoutPage.ts
└── support/ # Support files
├── commands.ts
└── e2e.ts
- Clone the repository
- Install dependencies:
npm install - Set up environment variables:
- Create a
cypress.env.jsonfile (already included but should not be committed to version control in a real project) - Or use a
.envfile with the necessary credentials
- Create a
Run all tests:
npm test
Run tests in headless mode:
npm run test:headless
Run specific test flow:
npm run test:success # Successful order flow
npm run test:failure # Failed order flow
Open Cypress GUI:
npm run cypress:open
The following environment variables are used:
CYPRESS_USERNAME: Username for successful loginCYPRESS_PASSWORD: Password for both usersCYPRESS_FAILURE_USERNAME: Username for the user with failed payments
These can be set in:
cypress.env.jsonfile (for local development).envfile- CI/CD pipeline environment variables
The tests are designed for the mock e-commerce application located at:
https://v0-imagine-deals.vercel.app
- This is a demo project for testing purposes only
- The application simulates payment scenarios:
- Any total ending in .99 will simulate a declined payment
- Any total ending in .88 will simulate a network error