Example test suite with Playwright and Jest with jest-playwright-preset to configure the Jest environment for browser tests. The example uses Visual Studio Codespaces but can be extended to work with any web app with authentication.
- Isolated context per test: Uses
context
global which is an isolated browser context per test. - Screenshots on failure: Auto-capture screenshots of failed test pages (in the
screenshots
directory). - Login only once: Uses
globalSetup
in Jest config to setup a one-time login which is then re-used in tests. - TypeScript support
Install dependencies
npm install
Note: Running tests requires test account credentials set as
USER
andPASSWORD
environment variables.
Run all tests in headless mode.
npm test # or npx jest
Run all tests in a particular browser and headful mode.
HEADLESS=false BROWSER=chromium npm test
Run single test by spec name (see other options in Jest CLI config).
BROWSER=chromium npx jest -t "should be logged in"
- Add support for using the VS Code debugger
- Add support for junit reports
- Replace environment variables with something more cross-platform