A robust testing framework built with Cypress, Cucumber, and TypeScript, providing a BDD approach to end-to-end testing for the SauceDemo e-commerce website with strong typing support.
- β BDD Testing - Use Gherkin syntax for human-readable tests
- β TypeScript Integration - Strong typing for better code quality and developer experience
- β Page Object Model - Organized, maintainable test structure
- β MochaAwesome Reports - Detailed HTML reports for test results
- β Custom Commands - Reusable Cypress commands for common operations and improved test readability
- Node.js (v18.x or higher)
- npm (v8.x or higher)
- Git
demo.mp4
git clone https://github.com/emanmhmd/cypress-cucumber-ts.git
cd cypress-cucumber-tsyarn installyarn test# 1. Install dependencies
yarn install
# 2. Run Cypress tests
npx cypress run
# 3. Verify reports exist
ls cypress/reports/mocha/*.json
# 4. Generate merged report
npx ts-node generateMochaReport.tsyarn test:feature --spec "cypress/e2e/features/auth.feature"yarn test:chrome
yarn test:firefox
yarn test:edgeyarn cypress:opencypress-cucumber-ts/
βββ cypress/
β βββ cucumber.json
β βββ e2e/
β β βββ features/ # Cucumber feature files
β β βββ step_definitions/ # Step definitions for Cucumber
β βββ fixtures/
β β βββ users.json # Test data
β βββ reports/
β β βββ features/
β β βββ html/
β β βββ mocha/ # MochaAwesome reports
β βββ support/
β β βββ pages/ # Page Objects
β β βββ commands.ts # Custom Cypress commands
β β βββ e2e.ts # Support file loaded before test files
β βββ videos/ # Test execution videos
βββ node_modules/
βββ reports/
βββ .gitignore
βββ cypress.config.ts # Cypress configuration
βββ generateMochaReport.ts # Report generation script
βββ package-lock.json
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ yarn.lock
This project uses MochaAwesome for generating test reports.
cypress/
βββ reports/
β βββ html/ # HTML report output
β β βββ index.html # Main HTML report
β βββ mocha/ # JSON report files
Reports are automatically generated after test runs. To manually generate reports:
# Verify reports exist
ls cypress/reports/mocha/*.json
# Generate merged report
npx ts-node generateMochaReport.ts
# Open the generated report
open cypress/reports/mochareports/report.htmlThis framework includes the following test scenarios:
- Verify that users can successfully log in with valid credentials
- Verify that the system displays an error message with invalid credentials
- Verify that locked out users cannot access the system
- Verify that user redirected to products page after successful login
- Verify that user with no permission can't add items to the cart
- Verify that user can log out successfully
- Verify that user can't access any page without login
- Verify that user can add items to the cart
- Verify that user can remove items from the cart
- Verify that user can checkout successfully
- Verify that user can't checkout without adding items to the cart
- Verify that user can't checkout without login
- Verify that checkout form requires first name
- Verify that checkout form requires last name
- Verify that checkout form requires zip code
- Verify that cart remembers items when refreshing the page
- Verify cart empties after order completes
Cypress automatically captures videos of test runs, which can be found in the cypress/videos directory after test execution.
# After running tests, videos will be available in the cypress/videos directory
open cypress/videosVideo recording settings can be configured in the cypress.config.ts file:
// cypress.config.ts
export default defineConfig({
e2e: {
video: true, // Enable/disable video recording
videoCompression: 32, // Compression quality (0-100)
videosFolder: 'cypress/videos', // Videos output directory
},
});