m-pujic-levi9-com/playwright-e2e-tests
关于
Playwright E2E Test Framework
系统与基础设施可以做什么
- Manually triggered via workflow_dispatch.
- Automatically scheduled to run every Monday at 9:00 AM (UTC).
- Installs Node.js and caches Node modules for faster execution.
- Prepares Playwright binaries and their system dependencies.
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Playwright E2E Testing Framework
Playwright E2E Testing Framework project represents a starting point for writing tests in Playwright.
Provided tests are based on examples how to define and use utility functions, explicit wait for some element, usage of faker for generating random data and possible solutions for organizing tests using Page Object pattern.
IDE Setup
- Install Visual Studio Code
- Recommended extensions in Visual Studio Code:
- Install Node JS
- Clone the repository to your local system
- Open the project in Visual Studio Code and open the terminal
- Make sure the path to the project is correct
<local_path>\playwright-e2e-tests
- Make sure the path to the project is correct
- In the terminal, execute the following command:
npm install --legacy-peer-deps- The command will install all found in the package.json
Used Libraries
Launch Playwright and Execute Test Cases
Open the terminal inside <local_path>\playwright-e2e-tests and use the following commands to:
- Open the Playwright UI to execute test cases against default environment:
npx playwright test --ui - Execute all test cases without opening the Playwright UI against default environment:
npx playwright test - Environment variables:
ENV, which can have valueprodorlocal, depending on which environment you would like to execute your tests (if not defined,prodwill be used by default)produseshttps://automationintesting.onlineas app URLlocaluseshttp://localhostas app URL
- Test filtering using Tags:
- If not set all tests will be executed. Filtering tests using Tags is done with
--grepand--grep-invertcommand line flagsnpx playwright test --grep "@sanity"- Tests tagged with@sanitywill be filterednpx playwright test --grep-invert "@slow"- Tests not tagged with@slowwill be filterednpx playwright test --grep "(?=.*@management)(?=.*@room-management)"- Tests tagged with both@managementand@room-managementwill be filterednpx playwright test --grep "@booking|@contact"- Tests tagged with either@bookingor@contactwill be filtered
- If not set all tests will be executed. Filtering tests using Tags is done with
Example of above commands with possible variables:
ENV=local npx playwright test --ui- Open Playwright UI to execute tests against Local environmentENV=prod npx playwright test- Execute All tests without opening the Playwright UI against Production environment in all setup projects (browsers)ENV=local npx playwright test tests/admin-panel/login.spec.ts- Execute Login tests without opening the Playwright UI on Local environment in all setup projects (browsers)ENV=prod npx playwright test --grep "@booking|@contact"- Execute tests tagged with@bookingor@contact, without opening the Playwright UI on Production environment in all setup projects (browsers)ENV=prod npx playwright test --grep-invert "@room-management" --project chromium- Execute tests not tagged with@room-management, without opening the Playwright UI on Production environment only onchromiumproject (browser)
Local Docker Environment with Docker for Desktop
Before you proceed, you should install Docker Desktop depending on your OS and start it:
After Docker has been installed on your machine, open the terminal inside <local_path>\playwright-e2e-tests and use the following command:
docker compose -f ./docker-compose.restful-booker.yml up -d
That will start Restful Booker Platform locally.
After everything is up and running you will have Restful Booker Platform available at http://localhost.
Execute Playwright E2E Tests using GitHub Actions Workflows on GitHub
All GitHub Actions Workflows are configured in GitHub Folder yml files.
They all can be found by navigating to GitHub Repository > Actions.
There are 3 GitHub Actions Workflows setup for Playwright E2E Tests repository:
Playwright Tests
This workflow is designed to run comprehensive automated tests using Playwright across multiple browsers. It executes all Playwright E2E tests, including @slow tests, on the local environment using chromium, firefox and webkit browsers. It includes parallel test execution, detailed reporting, and scheduled runs to maintain reliability.
Status of all ongoing and previously executed Playwright Tests Workflow runs can be found here.
GitHub Action Workflow configuration file of this workflow is playwright.yml.
Playwright Tests: Key Features
Trigger Events:
- Manually triggered via
workflow_dispatch. - Automatically scheduled to run every Monday at 9:00 AM (UTC).
- Manually triggered via
Setup and Dependencies:
- Installs Node.js and caches Node modules for faster execution.
- Prepares Playwright binaries and their system dependencies.
- Validates the codebase with TypeScript type checks.
Test Execution:
- Executes tests for
chromium,firefox, andwebkitbrowsers. - Implements test sharding to run tests concurrently, improving efficiency.
- Executes tests for
Test Environment:
- Deploys multiple Docker-based microservices to emulate the testing environment, ensuring tests run against a realistic backend setup.
Reporting:
- Generates multiple types of test reports, including HTML, Monocart, and Allure.
- Merges test results and publishes them to GitHub Pages for easy access.
Playwright Tests: Workflow Overview
- Install Job
- Sets up the environment, installs dependencies, and validates the codebase with type checks.
- Test Job
- Executes Playwright tests in parallel across browsers and shards.
- Deploys Docker services to replicate the application environment.
- Uploads reports and test results as artifacts for post-test analysis.
- Report Job
- Consolidates and merges test reports from parallel runs.
- Generates Playwright HTML, Monocart, and Allure reports.
- Publishes the reports to GitHub Pages for easy sharing and review.
- Cleans up unnecessary artifacts to optimize storage usage.
Playwright Tests: Usage
To trigger the workflow:
- Manual Run: Go to the Actions tab in your GitHub repository, select the Playwright Tests workflow, and click
Run workflow.- :warning: This GitHub Actions publishes report on GitHub pages and because of that it can ONLY be executed on main branch. :warning:
- Scheduled Run: The workflow automatically runs every Monday at 9:00 AM UTC.
Playwright Tests: Reports
- Playwright HTML Report: Test report without execution history and trends.
- Monocart Report: Test report with execution history and trends..
- Allure Report: Test report with execution history and trends.
Access the reports via the GitHub Pages link provided in the workflow logs after execution, or click here.
Check - Sanity Tests
This GitHub Action ensures that essential functionality remains intact. It runs @sanity tagged tests on local environment using chromium, firefox and webkit browsers. It is triggered automatically on changes to specified parts of the repository or during pull requests targeting the main branch.
Status of all ongoing and previously executed Check - Sanity Tests Workflow runs can be found here.
GitHub Action Workflow configuration file of this workflow is check-sanity.yml.
Check - Sanity Tests: Key Features
Trigger Events: The workflow executes on:
- Push events to the
mainbranch, specifically when changes occur in:- Directories:
apis/,pages/,tests/,utils/ - Workflow file:
.github/workflows/sanity-check.yml - Configuration files:
playwright.config.ts,package-lock.json,package.json
- Directories:
- Pull request events targeting the
mainbranch:- Opened
- Reopened
- Synchronized
- Labeled
- Push events to the
Setup and Dependencies:
- Installs Node.js and caches Node modules for faster subsequent runs.
- Installs and caches Playwright binaries, along with their system dependencies.
- Runs TypeScript type checks to validate code integrity.
Test Environment:
- Deploys multiple Docker-based microservices to emulate the testing environment, ensuring tests run against a realistic backend setup.
Test Execution:
- Leverages Playwright to execute tests marked with the
@sanitytag, excluding tests marked with@slow. - Ensures essential application flows are thoroughly verified.
- Leverages Playwright to execute tests marked with the
Reports:
- Automatically generates and uploads an HTML report for the sanity test results, accessible via workflow artifacts.
Check - Sanity Tests: Workflow Overview
- Install Job
- Sets up the environment, installs dependencies, and ensures readiness for testing.
- Verifies code correctness with TypeScript type checks.
- Test Job
- Deploys test environment by initializing a set of microservices using Docker.
- Executes sanity tests using Playwright.
- Uploads a detailed HTML test report.
Check - Changed Tests
This GitHub Action is designed to streamline the testing process for pull requests. It identifies only the tests affected by the introduced changes and executes them on local environment using chromium, firefox and webkit browsers. It is triggered automatically during pull requests targeting the main branch.
Status of all ongoing and previously executed Check - Changed Tests Workflow runs can be found here.
GitHub Action Workflow configuration file of this workflow is check-changes.yml.
Check - Changed Tests: Key Features
Trigger Events: Automatically runs when a pull request targeting the
mainbranch is:- Opened
- Reopened
- Synchronized
- Labeled
Setup and Dependencies:
- Performs a full repository checkout for accurate diff comparisons.
- Sets up Node.js and caches Node modules to speed up subsequent runs.
- Installs and caches Playwright binaries, along with their system dependencies.
- Runs TypeScript type checks to validate code integrity.
Test Environment:
- Deploys multiple Docker-based microservices to emulate the testing environment, ensuring tests run against a realistic backend setup.
Test Execution:
- Leverages Playwright's
--only-changedoption to execute only the tests impacted by code changes, excluding tests marked with@slowto reduce feedback time and resource usage.
- Leverages Playwright's
Reports:
- Automatically generates and uploads an HTML report for Playwright test results, which can be accessed and reviewed directly from the workflow artifacts.
Check - Changed Tests: Workflow Overview
Install Job
- Sets up the environment, installs dependencies, and ensures everything is ready for test execution.
- Runs TypeScript type checks to ensure code validity.
Test Job
- Deploys test environment by initializing a set of microservices using Docker.
- Executes Playwright Tests for the affected files.
- Uploads a detailed HTML test report.
探索相关项目
加载中…