This repo is created for study purposes. The code produced here is done by following along the Udemy course Playwright JS Automation Testing from Scratch with Framework
Follow these steps once for the project environment (Windows PowerShell examples). Adjust if you use a different shell/OS.
-
Install Node.js (LTS) and npm
- Download and install from https://nodejs.org/. Confirm installation:
node -v npm -v
-
Install project dependencies
From the repository root run:
npm install
-
Install Playwright browsers
Playwright requires browser binaries; install them once after npm install:
npx playwright install
If you only need specific browsers, add the browser name, e.g.
npx playwright install chromium. -
If you plan to run Cucumber with TypeScript step definitions
- Install ts-node and typescript as dev-dependencies (if not already present):
npm install -D ts-node typescript
- Run cucumber with TypeScript support:
npx cucumber-js --require-module ts-node/register --require ./features/step_definitions --exit
Now continue with usage instructions below.
The training includes different types of testing, such as typescript, javascipt and cucumber. Here are some useful commands to execute the tests
Run all tests
npx playwright testRun only tests with a specific tag
npx playwright test --grep @WebSpecifiy the configuration file and the project to run
npx playwright test --config playwright.config1.js --project=safariRun only the tests that failed in the previous run
npx playwright test --last-failedRun Playwright tests headed (see browser UI):
npx playwright test --headedRe-run only the tests that failed in the last run (fast iteration):
npx playwright test --last-failedGenerate detailed traces for debugging (save artifacts under playwright-report/):
npx playwright test --trace onRun all cucumber tests in the suite. The --exit syntax closes the runner at the end so the test won't hang
npx cucumber-js --exitRun only a specific feature file
npx cucumber-js features/ErrorValidations.feature --exitRun tests with a specific tag
npx cucumber-js --tags "@Regression" --exitRun tests in parallel (example: run feature in parallel workers)
npx cucumber-js features/Ecommerce.feature --parallel 2 --exitGenerate HTML report for the test
npx cucumber-js --exit --format html:filename.html