This repository contains end-to-end (E2E) test suites and API test suites built with Playwright and Node.js. These tests target Automation Exercise to demonstrate user authentication flows and other scenarios based on their test cases.
- Overview
- Features
- Project Structure
- Getting Started
- Usage
- Configuration
- Continuous Integration
- Contributing
- License
- Framework: Playwright
- Language: JavaScript (Node.js)
- Test Runner: @playwright/test
- CI: GitHub Actions
- Fully Parallelized: Playwright’s parallel execution for faster feedback.
- Cross-Browser Tests: Configured to run in Chromium by default (easily extendable to Firefox and WebKit).
- Mocking & Assertions: Playwright’s powerful fixtures and test assertions.
- Automatic Reporting: Generates HTML, JSON, and GitHub Actions-friendly reports.
- GitHub Actions: Automated tests run on every push or pull request.
├── .github/
│ └── workflows/
│ └── playwright.yml # GitHub Actions workflow for running tests
├── tests/
│ ├── e2e/ # API test files
│ ├── helpers/
│ └── api/ # API test files
├── .gitignore
├── package.json
├── playwright.config.js # Core Playwright configuration
├── yarn.lock / package-lock.json # (Depending on your package manager)
└── README.md
tests/e2e
: All end-to-end tests, each focusing on a specific suite or feature.tests/helpers
: Utility functions and modules (e.g., user data generation, common flows likeregisterUser
)..github/workflows/playwright.yml
: Defines continuous integration steps on GitHub Actions.playwright.config.js
: Central configuration for browser settings, timeouts, environment, etc.
-
Clone this repository:
git clone https://github.com/your-username/playwright-demo.git cd playwright-demo
-
Install dependencies:
# If using Yarn yarn install # Or using npm npm install
-
Install Playwright browsers:
# Yarn yarn playwright install --with-deps # npm npx playwright install --with-deps
# With Yarn
yarn playwright test
# With npm
npx playwright test
This project includes two “projects” in playwright.config.js
: e2e
(UI tests) and api
(API tests, if any).
# E2E tests only
yarn test:e2e
# API tests only
yarn test:api
After tests finish, an HTML report is generated in the /reports
or /playwright-report
directory (based on your config).
yarn playwright show-report
Most test settings (timeouts, browsers, parallelization) are configured inside playwright.config.js
. Key options include:
retries
: Number of times to retry failing tests.reporter
: Reporters for console, HTML, JSON, or GitHub.use
: Default test settings (e.g., browser, viewport, tracing, screenshots).projects
: Separate config for E2E vs. API tests (different base URLs, etc.).
Update these as needed for your environment (e.g., adjusting headless
, specifying different base URLs).
This repo is preconfigured to run tests in GitHub Actions whenever code is pushed to main
or when a pull request is opened. The workflow file includes steps to:
- Checkout code
- Install Node.js
- Install Playwright browsers
- Execute all tests
- Upload the Playwright report as an artifact
If tests pass, the build will succeed. If not, you can review logs and attached artifacts on the GitHub Actions page.
We welcome contributions, bug reports, and feature requests. To contribute:
- Fork the repository.
- Create a new feature branch.
- Submit a Pull Request explaining your changes.
Please ensure tests pass locally before submitting your PR.
This project is licensed under the MIT License. You are free to use and adapt this repository for your own projects.
Happy Testing! If you have any questions or suggestions, feel free to open an issue or submit a pull request.