This is a comprehensive test automation framework built with CodeceptJS, Playwright, TypeScript, Gherkin, and Allure Reporting. The framework includes both Web UI and API test automation suites.
π Latest Allure Report: View Online
- Overview
- Technology Stack
- Project Structure
- Installation
- Environment Variables
- Running Tests
- Test Scenarios
- Allure Reports
- CI/CD with GitHub Actions
- Approach & Design Decisions
This framework implements test automation for:
- Web UI Testing: SauceDemo e-commerce website (https://www.saucedemo.com)
- API Testing: ReqRes API endpoints (https://reqres.in)
All tests are written using Gherkin syntax (BDD) and executed with CodeceptJS using Playwright as the browser automation engine.
- CodeceptJS (v3.5.1): Test framework with BDD support
- Playwright (v1.40.0): Browser automation
- TypeScript (v5.3.3): Type-safe JavaScript
- Gherkin: BDD syntax for test scenarios
- Allure Report: Test reporting and visualization
- REST Helper: API testing capabilities
playwright-gherkin-allure/
βββ features/
β βββ web/ # Web UI test scenarios
β β βββ web_scenario_1.feature
β β βββ web_scenario_2.feature
β β βββ web_scenario_3.feature
β β βββ web_scenario_4.feature
β βββ api/ # API test scenarios
β βββ api_scenario_1.feature
β βββ api_scenario_2.feature
β βββ api_scenario_3.feature
β βββ api_scenario_4.feature
β βββ api_scenario_5.feature
βββ step_definitions/ # Step definitions for Gherkin scenarios
β βββ web_steps.ts
β βββ api_steps.ts
βββ pages/ # Page Object Model classes
β βββ LoginPage.ts
β βββ ProductsPage.ts
β βββ CartPage.ts
β βββ CheckoutPage.ts
β βββ ItemPage.ts
βββ helpers/ # Helper utilities
β βββ webHelper.ts # Web locator helpers
β βββ apiHelper.ts # API helper functions
βββ scripts/ # Utility scripts
β βββ allure-serve.ts # Allure server wrapper for Windows (TypeScript)
βββ .github/ # GitHub Actions workflows
β βββ workflows/
β βββ ci.yml # CI/CD pipeline configuration
βββ codecept.conf.ts # CodeceptJS configuration
βββ tsconfig.json # TypeScript configuration
βββ package.json # Dependencies and scripts
βββ steps_file.ts # CodeceptJS steps file
βββ .env.example # Example environment variables
βββ .env # Environment variables (not in git)
βββ README.md # This file
- Node.js (v16 or higher)
- npm (comes with Node.js)
- Java JDK or JRE (required for Allure Reports) - Download from Adoptium or Oracle
npm installThis will install all required packages:
- CodeceptJS
- Playwright
- TypeScript
- Allure reporter
- dotenv (for environment variables)
- And their dependencies
Copy the example environment file and customize if needed:
copy .env.example .envThe .env file contains configuration for:
- Web application URL
- API endpoint URL
- Browser settings
- Timeout values
- Test credentials
Note: The .env file is already configured with default values, so this step is optional. See Environment Variables section for details.
npx playwright install chromiumOr install all browsers:
npx playwright installAllure Reports requires Java to generate HTML reports. Please install Java:
Option 1: Install Java JDK (Recommended)
- Download from: https://adoptium.net/ (OpenJDK - Recommended)
- Or from: https://www.oracle.com/java/technologies/downloads/
- Install and verify with:
java -version
Option 2: Verify Installation Check if Java is installed:
java -versionYou should see output showing the Java version (e.g., java 17.0.12 or java 21.0.1).
Allure commandline is already included as a dev dependency in this project. The framework uses npx allure commands or a custom TypeScript wrapper script (scripts/allure-serve.ts) that automatically handles the Allure JAR file.
No additional installation is required! The framework will work out of the box after installing dependencies.
If you prefer a global installation for system-wide access, you can install it separately, but it's not necessary for this project.
All configuration is managed through environment variables. Copy .env.example to .env and customize as needed:
cp .env.example .envWEB_URL- Web application URL (default:https://www.saucedemo.com)
API_URL- API endpoint URL (default:https://reqres.in/api)
API_KEY- API key for authenticationAPI_TOKEN- Bearer token for authentication (takes priority over API_KEY)API_KEY_HEADER_NAME- Custom header name for API keyAPI_KEY_HEADER- Alternative variable to store API key value
BROWSER- Browser to use:chromium,firefox, orwebkit(default:chromium)HEADED- Run in headed mode:trueorfalse(default:false)HEADLESS- Run in headless mode:trueorfalse(default:true)
WAIT_FOR_TIMEOUT- Default wait timeout (default:10000)WAIT_FOR_ACTION- Wait time between actions (default:1000)TIMEOUT- General timeout (default:30000)
WINDOW_SIZE- Browser window size (default:1920x1080)
All users share the same password. These are test credentials and safe to commit.
STANDARD_USER- Standard user username (default:standard_user)PROBLEM_USER- Problem user username (default:problem_user)LOCKED_OUT_USER- Locked out user username (default:locked_out_user)PERFORMANCE_GLITCH_USER- Performance glitch user username (default:performance_glitch_user)ERROR_USER- Error user username (default:error_user)VISUAL_USER- Visual user username (default:visual_user)PASSWORD- Password for all users (default:secret_sauce)
ALLURE_OUTPUT_DIR- Directory for Allure results (default:./output/allure)
The framework automatically loads environment variables from .env file using dotenv. All variables have default values, so creating .env is optional unless you need to override defaults.
npm testnpm run test:webnpm run test:apinpm run test:headednpm run test:headlessnpm run test:allThis command will:
- Run all tests
- Generate Allure results
- Start Allure server and open report in browser
npm run test:web:reportnpm run test:api:reportThe latest Allure report from CI/CD pipeline is automatically deployed to GitHub Pages and available at:
π https://pavlovic-bojan.github.io/playwright-gherkin-allure/
This report is updated automatically after each successful workflow run on the main branch.
After running tests locally, generate the Allure report:
npm run allure:generateOpen the generated report in your default browser:
npm run allure:openStart a local server to view the report:
npm run allure:serveThe report will be available at http://localhost:XXXX (port will be shown in terminal).
Note: On Windows systems with paths containing spaces, the framework uses a custom TypeScript wrapper script (scripts/allure-serve.ts) to ensure Allure server starts correctly. This script automatically finds the Allure JAR file and handles path escaping. The script is executed using ts-node.
- Login as standard user
- Add all items to cart
- Remove third item
- Complete checkout
- Validate order confirmation
- Login as problem user
- Find item by name
- Add to cart from item detail page
- Validate item in cart
- Login as standard user
- Sort products by name (A to Z)
- Validate sorting
- Attempt login as locked_out_user
- Validate login failure and error message
- Get list of users
- Validate success response
- Print users with odd ID numbers
- Create new user
- Validate creation success
- Validate creation date is today
- Update existing user
- Validate update success
- Validate response matches request body
- Test API with delay parameters (0 and 3 seconds)
- Validate response time < 1 second
- Attempt login without password
- Validate login failure (400 status)
This project includes GitHub Actions workflows for continuous integration. The workflows automatically run tests on every push and pull request to main or develop branches.
The project includes three separate workflows located in .github/workflows/:
-
Run All Tests (
ci.yml) - Runs both Web and API tests- Latest report: https://pavlovic-bojan.github.io/playwright-gherkin-allure/
-
Run Web Tests (
ci-web.yml) - Runs only Web UI tests -
Run API Tests (
ci-api.yml) - Runs only API tests
All workflows can be triggered manually via the GitHub Actions UI or automatically on push/PR.
Each workflow performs the following steps:
- Checkout Code - Retrieves the latest code from repository
- Setup Node.js - Installs Node.js 20 with npm caching
- Setup Java - Installs Java 17 (required for Allure Reports)
- Install Dependencies - Runs
npm cito install all dependencies - Install Playwright Browsers - Installs Chromium browser (Web tests only)
- Run Tests - Executes tests with environment variables
- Generate Allure Report - Creates Allure report from test results
- Upload Artifacts - Uploads Allure report and test results as artifacts
- Deploy to GitHub Pages - Automatically deploys report to GitHub Pages (main branch only)
The workflow uses GitHub Secrets for sensitive configuration. You can set these in your repository settings under Settings β Secrets and variables β Actions.
Optional Secrets (with defaults):
WEB_URL(default:https://www.saucedemo.com)API_URL(default:https://reqres.in/api)STANDARD_USER(default:standard_user)PROBLEM_USER(default:problem_user)LOCKED_OUT_USER(default:locked_out_user)PERFORMANCE_GLITCH_USER(default:performance_glitch_user)ERROR_USER(default:error_user)VISUAL_USER(default:visual_user)PASSWORD(default:secret_sauce)API_KEY(optional)API_TOKEN(optional)
After a workflow runs:
-
View Report Online: The latest Allure report is automatically deployed to GitHub Pages:
-
Download Artifacts: Go to the Actions tab in your GitHub repository:
- Click on the workflow run to see details
- Download allure-report artifact to view the Allure report locally
- Download test-results artifact to see detailed test output
To test the CI/CD workflow locally, you can use act:
act -j testOr install dependencies and run tests manually:
npm ci
npx playwright install --with-deps chromium
npm test- BDD Support: Native Gherkin support without additional setup
- Multiple Helpers: Easy integration of Playwright and REST helpers
- Page Objects: Built-in support for Page Object Model
- Allure Integration: Seamless Allure reporting plugin
- TypeScript Support: Full TypeScript support out of the box
- Maintainability: Centralized element locators
- Reusability: Page methods can be reused across tests
- DRY Principle: No code duplication
- Readability: Clear separation of concerns
- Readability: Tests are readable by non-technical stakeholders
- Documentation: Feature files serve as living documentation
- Collaboration: Business analysts can write/validate scenarios
- Maintainability: Clear test intent and structure
- Rich Reports: Detailed test execution reports with screenshots
- History: Track test execution over time
- Attachments: Support for logs, screenshots, and custom data
- Integration: Easy CI/CD integration
-
Separation of Concerns:
- Feature files (Gherkin) define test scenarios
- Step definitions map Gherkin steps to code
- Page objects encapsulate page interactions
- Configuration is centralized
-
DRY Principle:
- Reusable page objects
- Common step definitions
- Centralized user credentials
- Shared utilities
-
Maintainability:
- TypeScript for type safety
- Clear naming conventions
- Modular structure
- Comprehensive documentation
- Playwright Helper: Configured for SauceDemo website
- REST Helper: Configured for ReqRes API
- Allure Plugin: Enabled for test reporting
- Gherkin: Configured to use feature files and step definitions
See Environment Variables section for complete configuration options.
After running tests, you should see:
- All scenarios passing (or failing with clear error messages)
- Allure report with detailed execution information
- Console output with test progress
- Screenshots and traces (if enabled)
Solution: Run npx playwright install chromium
Solution:
- Ensure Java is installed:
java -version - Ensure Allure commandline is installed via npm:
npm install --save-dev allure-commandline - On Windows with paths containing spaces, the custom wrapper script handles this automatically
Solution: The framework uses a custom wrapper script that handles path issues. If problems persist, use npm run allure:generate && npm run allure:open instead.
Solution: Run npm install to ensure all dependencies are installed
Solution: Increase timeout in codecept.conf.ts or check network connectivity
ISC
Note: This framework follows best practices for test automation including Page Object Model, BDD approach, and comprehensive reporting. All code follows DRY principles and includes proper error handling and validation.