Skip to content

A sample repository for teams to use as a guide to set up Playwright in their own projects.

License

Notifications You must be signed in to change notification settings

hmcts/tcoe-playwright-example

Repository files navigation

Here's a more general README template for a Playwright-based project repository:

Playwright Project Template

This repository serves as a template for UI test automation using Playwright. It is designed to work across multiple browsers and environments, providing flexibility in writing, running, and debugging tests.

Features

  • Cross-browser testing: Supports Chromium, Firefox, and WebKit.
  • Responsive testing: Test on different viewports (mobile, tablet, desktop).
  • Parallel test execution: Run tests concurrently for faster feedback.
  • Accessibility tests: Integrate basic accessibility checks using libraries like Axe Core.
  • CI/CD ready: Sample Jenkinsfile included for integrating with your CI pipeline.
  • Test tagging: Use tags like @a11y for accessibility, @smoke for smoke tests, and more.

Project Structure

The repository follows a Page Object Model (POM) design pattern, ensuring that locators and actions are well-organized and reusable.

├── tests/                  # Test files
├── pages/                  # Page objects for different pages of the application
├── components/             # Common components shared across pages
├── fixtures/               # Fixtures for setup and teardown
├── helpers/                # Utility functions or common tasks (e.g., login)
├── reports/                # Generated test reports

TCoE Best Practices for setting up playwright in your service can be found in the playwright-e2e/readme.md.

Getting Started

Prerequisites

Ensure you have the following installed on your machine:

  • Node.js (v14+)
  • Yarn

Installation

Clone the repository and install the dependencies:

git clone https://github.com/your-username/playwright-template.git
cd playwright-template
yarn install

Running Tests

Run all tests using the Playwright test runner:

yarn playwright test

To run a specific test file:

yarn playwright test tests/example.spec.ts

To run tests on a specific browser:

yarn playwright test --project=chromium
yarn playwright test --project=firefox
yarn playwright test --project=webkit

Test Tagging

You can use tags to group tests, for example:

yarn playwright test --grep @smoke

Debugging Tests

To run tests with tracing, screenshots, and video recording for debugging purposes:

yarn playwright test --trace on --video on --screenshot on

Accessibility Tests

Run accessibility checks as part of your tests using Axe Core:

yarn playwright test --grep @a11y

Running in CI

To run tests in CI, ensure that the Playwright dependencies are installed in the CI environment:

yarn playwright install

This template provides a general structure and instructions for setting up and running Playwright tests while making the project CI/CD-friendly and easy to scale.

About

A sample repository for teams to use as a guide to set up Playwright in their own projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •