Sample project to demonstrate Tests written with Playwright with TypeScript.
- Git(I've used version
2.56.1while writing this doc) - Node.js (I've used version
v24while writing this doc) - Visual Studio Code(I've used version
Stable Buildwhile writing this doc) - Playwright Extension(Install the official extension in the Visual Studio Code)
To clone and run this project, you will need:
A terminal or command prompt to run the commands
git clone <repository_url>Navigate into the cloned project directory:
cd <project_directory>Install system dependencies with the following command:
npm installInstall Playwright browsers and OS dependencies with the following command:
npx playwright install --with-depsCheck it out the following test files:
- .\tests\accessibility_test.spec.ts - Accessibility testing
- .\tests\api_test.spec.ts - API testing
- .\tests\visual_test.spec.ts - Visual testing
- .\tests\web_test.spec.ts - Web testing
| Package | Responsibility |
|---|---|
| data | responsible for managing test data |
| locators | responsible for identifying web elements |
| pages | responsible for page actions (navigation, (fills, types), clicks, etc.) |
| playwright.config.ts | responsible for configuring the Playwright test runner |
| tests | responsible for executing the test suite |
| playwright-report | responsible for storing the test reports generated by Playwright |
| test-results | responsible for storing the test results generated by Playwright |
Inside that directory, you can run several commands:
Updates the snapshots for visual tests.
npx playwright test tests/visual/visual.spec.ts --update-snapshotsRuns the tests for the web project.
npx playwright test --project=webRuns the tests for the API project.
npx playwright test --project=apiRuns the tests for the visual project.
npx playwright test --project=visualRuns the tests for the accessibility project.
npx playwright test --project=accessibilityStarts the interactive UI mode.
npx playwright test --uiRuns the tests in debug mode.
npx playwright test --debugGenerates test code using the Codegen tool.
npx playwright codegenRuns all the tests.
npx playwright testTo see the status report, you can run the command:
npx playwright show-report