A comprehensive E2E automation framework built with Selenium WebDriver, Jest, and Cucumber.js following the Page Object Model (POM) pattern.
- π Features
- π Project Structure
- π οΈ Setup
- βοΈ Configuration
- π§ͺ Running Tests
- π Reports
- ποΈ Architecture
- π¦ CI/CD Pipeline (GitHub Actions)
- π§ Development
- π Example Test
- π€ Contributing
- π License
- Selenium WebDriver for browser automation
- Cucumber.js for BDD-style feature files
- Jest for unit testing helpers and factories
- Page Object Model with separated Elements layer
- HTML Reports for both E2E and unit tests
- ESLint with Airbnb configuration
- Husky for Git hooks (pre-commit linting, commit message validation)
- Environment-based configuration
- Screenshot capture on test failures
βββ .husky/ # Git hooks
βββ .vscode/ # VS Code settings
βββ reports/ # Test reports and screenshots
β βββ cucumber/ # Cucumber HTML reports
β βββ jest/ # Jest HTML reports
β βββ screenshots/ # Failure screenshots
βββ src/
β βββ config/ # Configuration files
β β βββ env.js # Environment configuration
β β βββ selenium.js # WebDriver setup
β β βββ cucumber.js # Cucumber hooks
β β βββ jest.setup.js # Jest setup
β βββ data/
β β βββ factories/ # Test data factories
β β βββ userFactory.js
β βββ elements/ # Element selectors
β β βββ home.elements.js
β βββ helpers/ # Utility functions
β β βββ wait.js # Wait helpers
β β βββ assert.js # Assertion helpers
β βββ pages/ # Page Object classes
β β βββ base.page.js # Base page class
β β βββ home.page.js # Home page class
β βββ tests/
β βββ features/ # Cucumber feature files
β β βββ home.feature
β βββ step-definitions/ # Step definition files
β βββ home.steps.js
βββ __tests__/ # Jest unit tests
β βββ userFactory.test.js
βββ tools/ # Utility scripts
β βββ cucumber-html-report.js
βββ Configuration files...
- Node.js (>= 18)
- Chrome/Firefox/Edge browser
- ChromeDriver/GeckoDriver/EdgeDriver (for local execution)
-
Clone the repository
-
Install dependencies:
npm install
-
Copy environment file:
cp .env.example .env
-
Initialize Husky:
npm run prepare
Edit .env file to configure:
BASE_URL=https://gadget-shop-complete-xf3n.bolt.host
BROWSER=chrome # chrome, firefox, edge
HEADLESS=true # true/false
DEFAULT_TIMEOUT=30000 # milliseconds# Run all E2E tests
npm run test:e2e
# Generate Cucumber HTML report
npm run report:cucumber# Run unit tests
npm run test:unit
# Run all tests
npm run test:all# Check code style
npm run lint
# Fix linting issues
npm run lint:fix- Cucumber Reports:
reports/cucumber/index.html - Jest Reports:
reports/jest/report.html - Screenshots:
reports/screenshots/(on test failures)
- Elements Layer: Centralized selectors (
src/elements/) - Page Layer: Page interactions (
src/pages/) - Step Definitions: Test orchestration (
src/tests/step-definitions/)
- Environment:
src/config/env.js - WebDriver:
src/config/selenium.js - Hooks:
src/config/cucumber.js
- Wait Helpers: Custom wait conditions
- Assert Helpers: Enhanced assertions
- Data Factories: Test data generation with Faker.js
- Create Feature File: Add
.featurefile insrc/tests/features/ - Add Elements: Define selectors in
src/elements/ - Create Page Object: Implement page class in
src/pages/ - Write Step Definitions: Add steps in
src/tests/step-definitions/
- ESLint with Airbnb configuration
- Pre-commit hooks for linting
- Conventional commit messages
- Automatic screenshot capture on failures
The framework includes comprehensive GitHub Actions workflows for automated testing and deployment:
Triggered on push to main and develop branches:
- Linting & Quality: ESLint validation with Airbnb configuration
- Commit Validation: Commitlint checks for conventional commit messages
- Unit Tests: Jest tests with coverage reporting and HTML output
- E2E Tests: Cucumber + Selenium tests in headless Chrome
- Artifacts: Automatic upload of test reports and failure screenshots
- Environment: Node.js 20.x with Chrome/ChromeDriver setup
Triggered on pull requests to main and develop:
- Code Quality: ESLint checks with inline PR comments
- Commit Messages: Commitlint validation for PR commits
- Unit Testing: Fast Jest execution for quick feedback
- PR Comments: Automated status updates on PR with test results
Triggered on Git tags (e.g., v1.0.0):
- Full Test Suite: Complete E2E and unit test execution
- Release Notes: Automatic generation from commit history
- GitHub Release: Creates release with artifacts and reports
- Artifact Retention: 90-day retention for release reports
- Parallel Execution: Unit and E2E tests run in parallel for faster feedback
- Headless Testing: Chrome headless mode for reliable CI execution
- Artifact Management: Test reports, screenshots, and logs preserved
- Multi-Environment: Support for different test environments via secrets
- Failure Handling: Screenshot capture and detailed error reporting
- Cache Optimization: Node modules and browser binaries cached
# Smoke tests (quick validation)
npm run test:e2e:smoke
# Regression tests (comprehensive)
npm run test:e2e:regression
# Critical path tests
npm run test:e2e -- --tags "@critical"The workflows are configured for:
- Node.js: LTS 20.x for stability
- Browsers: Chrome with ChromeDriver auto-installation
- Timeouts: 60-second step timeout, 30-second Jest timeout
- Reporting: JSON and HTML formats with artifact upload
- Security: Environment variables and secrets management
Feature: Home Page
Scenario: Home page loads successfully
Given I am on the home page
When the page finishes loading
Then I should see the main content
And I should see the header- Follow conventional commit messages
- Run linting before commits
- Add tests for new features
- Update documentation as needed
MIT License