This project is a skeleton setup for Playwright, including examples for core functionalities such as page objects, fixtures, and tags/annotations. Follow the instructions below to set up and run the tests.
-
Install Node.js and npm
- Download and install Node.js from nodejs.org.
-
Install Project Dependencies
- Navigate to the project directory and run the following command to install all necessary dependencies: npm install
Run all Tests for all projects via npx playwright test
The dotenv and cross-env packages are now used, for dynamic loading of env files. The default env loaded when no env is provided is /env/.env.prod
.
A different env can be provided by npx cross-env ENV=<name> <runTests>
.
This command should work on all machines and environments.
Example: npx cross-env ENV=local npm run dummyTests
The project includes several npm scripts to facilitate running tests. Here are the available shortcuts:
-
Run Debug Last Failed Test
- This script runs the last failed test in debug mode:
npm run debugLastFailedTest - This is useful for debugging purposes, allowing you to identify and fix issues.
- This script runs the last failed test in debug mode:
-
Run Dummy Tests
- This script runs tests tagged with
@dummyTag
for thechromium
project:
npm run dummyTests - Use this to quickly run a subset of tests that are marked as dummy tests.
- This script runs tests tagged with
-
Run Desktop Tests
- This script runs tests for the desktop
chromium
,firefox
andwebkit
projects:
npm run desktopTests - This is useful for testing on desktop browser configurations.
- This script runs tests for the desktop
-
Run Mobile Tests
- This script runs tests for both
Mobile Chrome
andMobile Safari
projects:
npm run mobileTests - This is useful for testing on mobile browser configurations.
- This script runs tests for both
- Page Objects: The project follows the page object model to organize and manage page-specific code.
- Fixtures: Fixtures are used to set up the test environment, providing reusable data and context for tests.
- Tags/Annotations: Tags are used to categorize and selectively run tests.