Install Playwright:
npm init playwright@latest
Configure .env file
Rename .env.example to .env and add values accordingly
Adding New Variables Later
Locally:
Add to .env: NEW_VARIABLE=value
Add to .env.example: NEW_VARIABLE=
Add to mainConfig.js: newVariable: process.env.NEW_VARIABLE || ''
On GitHub:
Go to Settings → Secrets and variables → Actions
Click on ENV_FILE secret
Click Update
Add the new line: NEW_VARIABLE=value
Click Update secret
Run All Tests
Run all tests under the 'tests' folder. By default, tests (test files) run in parallel and also in parallel on 2 browsers (Chrome and Safari).
Headless
npx playwright test
npx playwright test --project=chrome
npx playwright test --project=safari
Headed
npx playwright test --project=chrome --headed
disable parallel execution by setting workers to '1'
npx playwright test --project=chrome --workers 1
Run Test
npx playwright test tests/0003_create-org.spec.js --project=chrome
npx playwright test tests/0003_create-org.spec.js --project=chrome --headed
npx playwright test tests/0003_create-org.spec.js --project=chrome --ui
To skip globalSetup (initialSetup.js), add SKIP_SETUP=true
SKIP_SETUP=true npx playwright test tests/0001_bypassLogin.spec.js --project=chrome --headed
Run cleanup tests:
npx playwright test --config=playwright.cleanup.config.js
Run a cleanup test:
npx playwright test tests_cleanup/0001_cleanup.spec.js --config=playwright.cleanup.config.js --headed
Run create cluster test for performance testing:
npx playwright test tests_perf/0001_create-cluster-perf.spec.js --config=playwright.perf.config.js --headed
Run the tests Only for the self hosted cluster - localhost harperdb
npx playwright test tests/0007_self-hosted-cluster.spec.js
Run all the tests Without the self hosted harperdb
npx playwright test --grep-invert "0007_self-hosted-cluster.spec.js" --project=chrome
Show HTML Report
npx playwright show-report
Analyze a test trace
npx playwright show-trace path/to/trace.zip