Playwright w. Typescript
- Create a directory, then navigate to it
- Initialize npm:
npm init -y
- Install playwright, choose typescript:
npm init playwright@latest
- For API Testing - Fake data:
npm install --save-dev @faker-js/faker
- For API Testing - Fake date:
npm install --save-dev luxon
- For API Testing - Clean Folder Before Test Run:
npm install --save-dev rimraf
- For Accessibility Testing -
npm install @axe-core/playwright
- Run the end-to-end tests:
npx playwright test
- Start interactive UI mode:
npx playwright
- Run tests in a distinct browser:
npx playwright test --project=chromium
- Run a specific test:
npx playwright test <file>
- Run tests in debug mode:
npx playwright test --debug
- Run tests by tag (make sure you add them to the test description):
npx playwright test --grep "@tag"
Pesonally I like using:
..tests
|_components
|_test_name.spec.js
|_api
|_test_name.spec.js
|_e2e
|_page-objects
|_page-locators
|_specs