https://github.com/arjunattam/try-jest-playwright
https://github.com/arjunattam/try-jest-playwright
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arjunattam/try-jest-playwright
- Owner: arjunattam
- Created: 2020-07-14T21:52:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T11:30:10.000Z (over 3 years ago)
- Last Synced: 2024-10-18T07:17:28.664Z (over 1 year ago)
- Language: JavaScript
- Size: 827 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# try-jest-playwright
Example test suite with [Playwright](https://playwright.dev) and [Jest](https://jestjs.io) with [jest-playwright-preset](https://github.com/playwright-community/jest-playwright) to configure the Jest environment for browser tests. The example uses [Visual Studio Codespaces](https://online.visualstudio.com/) but can be extended to work with any web app with authentication.
## Features
* **Isolated context per test**: Uses `context` global which is an isolated [browser context](https://playwright.dev/#version=v1.2.1&path=docs%2Fcore-concepts.md&q=browser-contexts) 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
## Usage
Install dependencies
```sh
npm install
```
> **Note**: Running tests requires test account credentials set as `USER` and `PASSWORD` environment variables.
Run all tests in headless mode.
```sh
npm test # or npx jest
```
Run all tests in a particular browser and headful mode.
```sh
HEADLESS=false BROWSER=chromium npm test
```
Run single test by spec name (see [other options in Jest CLI config](https://jestjs.io/docs/en/cli)).
```sh
BROWSER=chromium npx jest -t "should be logged in"
```
## Future work
* Add support for using the VS Code debugger
* Add support for junit reports
* Replace environment variables with something more cross-platform