{"id":13588831,"url":"https://github.com/playwright-community/jest-playwright","last_synced_at":"2025-05-15T03:05:24.977Z","repository":{"id":39788434,"uuid":"237189930","full_name":"playwright-community/jest-playwright","owner":"playwright-community","description":"Running tests using Jest \u0026 Playwright ","archived":false,"fork":false,"pushed_at":"2023-11-17T10:52:42.000Z","size":2907,"stargazers_count":537,"open_issues_count":16,"forks_count":75,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-30T20:07:20.715Z","etag":null,"topics":["jest-environment","jest-playwright","playwright","testing","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/playwright-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-01-30T10:30:41.000Z","updated_at":"2025-03-06T12:14:51.000Z","dependencies_parsed_at":"2024-04-20T19:40:49.700Z","dependency_job_id":"441073a3-4fbc-458c-a10b-27352655af5c","html_url":"https://github.com/playwright-community/jest-playwright","commit_stats":{"total_commits":668,"total_committers":28,"mean_commits":"23.857142857142858","dds":0.5494011976047903,"last_synced_commit":"acb0e7b5af70e8821574d256e112d58951284595"},"previous_names":[],"tags_count":78,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-playwright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-playwright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-playwright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playwright-community%2Fjest-playwright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playwright-community","download_url":"https://codeload.github.com/playwright-community/jest-playwright/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247271473,"owners_count":20911586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jest-environment","jest-playwright","playwright","testing","typescript"],"created_at":"2024-08-01T15:06:58.014Z","updated_at":"2025-04-06T21:12:06.852Z","avatar_url":"https://github.com/playwright-community.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","typescript"],"sub_categories":[],"readme":"# Jest Playwright\n\n![CI](https://github.com/playwright-community/jest-playwright/workflows/Node.js/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/playwright-community/jest-playwright/badge.svg?branch=master)](https://coveralls.io/github/playwright-community/jest-playwright?branch=master)\n![npm](https://img.shields.io/npm/v/jest-playwright-preset)\n\n## ⚠️ We recommend the official [Playwright test-runner (@playwright/test)](https://playwright.dev/docs/test-intro) ⚠️\n\nIt's more flexible, lightweight, optimized for Playwright, and has TypeScript support out of the box. This doesn't mean, that we stop with maintaining this package.\n\n---\n\nRunning your tests using [Jest](https://github.com/facebook/jest) \u0026 [Playwright](https://github.com/microsoft/playwright)\n\n```bash\nnpm install -D jest jest-playwright-preset playwright\n```\n\nAlso you can use `jest-playwright-preset` with specific playwright packages:\n`playwright-webkit`, `playwright-chromium` and `playwright-firefox`\n\n```bash\nnpm install -D jest jest-playwright-preset playwright-firefox\n```\n\n## Requirements\n\n- Node.js 14+\n- Playwright 1.2.0+\n- Jest 28+\n\n## Usage\n\nUpdate your Jest configuration, either:\n\nwith `package.json`:\n\n```json\n\"jest\": {\n  \"preset\": \"jest-playwright-preset\"\n}\n```\n\nor with `jest.config.js`:\n\n```javascript\nmodule.exports = {\n  preset: 'jest-playwright-preset',\n}\n```\n\nAnd add the Jest command as in the script section of your `package.json`:\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"jest\"\n  }\n}\n```\n\nNow you can use Playwright in your tests:\n\n```js\n// example.test.js\nbeforeAll(async () =\u003e {\n  await page.goto('https://whatismybrowser.com/')\n})\n\ntest('should display correct browser', async () =\u003e {\n  const browser = await page.$eval('.string-major', (el) =\u003e el.innerHTML)\n  expect(browser).toContain('Chrome')\n})\n```\n\n### Notes\n\n`playwright` actions can take some time for execution, because of it `jest-playwright` overrides jest default timeout interval from 5 to 15 seconds.\nYou can change this interval with [`testTimeout`](https://jestjs.io/docs/en/configuration#testtimeout-number) in your `jest` configuration.\n\n## Configuration\n\nIt's recommend to use a separate Jest configuration `jest.e2e.config.js` for `jest-playwright` to gain speed improvements and by that to only use Playwright in the end-to-end tests. For that you have to use the `-c` flag when calling Jest and use the [`testMatch`](https://jestjs.io/docs/en/configuration#testmatch-arraystring) or [`testRegex`](https://jestjs.io/docs/en/configuration#testregex-string--arraystring) in your Jest config to split them.\n\nBe sure to remove any existing `testEnvironment` option from your Jest configuration. The `jest-playwright-preset` preset needs to manage that option itself.\n\nConfiguration options can be specified using a `jest-playwright.config.js` file at the root of your project:\n\n```js\n// jest-playwright.config.js\n\nmodule.exports = {\n  // Options...\n}\n```\n\nSimilar to Jest [globalSetup](https://jestjs.io/docs/next/configuration#globalsetup-string) configuration can except the export of an async function:\n\n```js\nmodule.exports = async () =\u003e {\n  await ...\n};\n```\n\nA custom path can be specified to the `jest-playwright.config.js` file within your `jest.config.js` file:\n\n```js\nprocess.env.JEST_PLAYWRIGHT_CONFIG = '/path/to/jest-playwright.config.js'\n```\n\nAlternatively, configuration options can specified using Jest's own [`testEnvironmentOptions`](https://jestjs.io/docs/en/configuration#testenvironmentoptions-object) option within your `jest.config.js` file:\n\n```js\n// jest.config.js\n\nmodule.exports = {\n  preset: 'jest-playwright-preset',\n  testEnvironmentOptions: {\n    'jest-playwright': {\n      // Options...\n    },\n  },\n}\n```\n\n### Options\n\n- `launchOptions` \u003c[object]\u003e. [All Playwright launch options](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchoptions) can be specified in config. Since it is JavaScript, you can use all stuff you need, including environment.\n- `launchType` \u003c[**LAUNCH**](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchoptions) | [**PERSISTENT**](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchpersistentcontextuserdatadir-options) | [**SERVER**](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchserveroptions)\u003e. Method to launch browser instance. `jest-playwright` attaches Playwright to an existing browser instance by default.\n- `connectOptions` \u003c[object]\u003e. [All Playwright connect options](https://playwright.dev/docs/api/class-browsertype#browsertypeconnectparams) can be specified in config.\n- `contextOptions` \u003c[object]\u003e. [All Playwright context options](https://playwright.dev/docs/api/class-browser#browsernewcontextoptions) can be specified in config.\n- [browsers](#browser-configuration) \u003c[(string | object)[]]\u003e. Define [browsers](https://playwright.dev/docs/api/class-browsertype/) to run tests in.\n  - `chromium` Each test runs Chromium (default).\n  - `firefox` Each test runs Firefox.\n  - `webkit` Each test runs Webkit.\n- [devices](#device-configuration) \u003c[(string | object)[] | RegExp]\u003e. Define a [devices](https://playwright.dev/docs/api/class-playwright/#playwrightdevices) to run tests in. Actual list of devices can be found [here](https://github.com/microsoft/playwright/blob/master/src/server/deviceDescriptors.js).\n- `exitOnPageError` \u003c[boolean]\u003e. Exits process on any page error. Defaults to `true`.\n- `collectCoverage` \u003c[boolean]\u003e. Enables the coverage collection of the `saveCoverage(page)` calls to the `.nyc_output/coverage.json` file.\n- `serverOptions` \u003c[object]\u003e. [All `jest-process-manager` options](https://github.com/playwright-community/jest-process-manager#options).\n- `selectors` \u003c[array]\u003e. Define [selectors](https://playwright.dev/docs/api/class-selectors/). Each selector must be an object with name and script properties.\n- `skipInitialization` \u003c[boolean]\u003e. Add you ability to skip first setup `playwright` process. Possible use cases can be found [here](https://github.com/playwright-community/jest-playwright/issues/424)\n- `resetContextPerTest` \u003c[boolean]\u003e. Option for opening a new context per test\n- `useDefaultBrowserType` \u003c[boolean]\u003e. [Sometimes](https://github.com/microsoft/playwright/issues/2787) `browser` + `device` combinations don't have any sense. With this option tests will be run with [`defaultBrowserType`](https://github.com/microsoft/playwright/pull/3731) of device. Pay attention that you should define **devices** to correct usage of this option.\n\n### Usage of process environment to define browser\n\nYou can control the browser with passing environment variable.\n\n```js\n// jest-playwright.config.js\nmodule.exports = {\n  browsers: [process.env.BROWSER],\n}\n```\n\n### Specific browser options\n\nFor `launchOptions`, `connectOptions` and `contextOptions` you can define special browser options.\n\n```js\n// jest-playwright.config.js\nmodule.exports = {\n  connectOptions: {\n    chromium: {\n      wsEndpoint: 'ws://chrome.proxy.com:4444'\n    },\n    firefox: {\n      wsEndpoint: 'ws://firefox.proxy.com:4444'\n    }\n  },\n  ...\n}\n```\n\n### Browser configuration\n\nThere are different ways to define devices in your configuration file:\n\n- You can use array of browser names:\n\n```js\nmodule.exports = {\n  browsers: [\"chromium\", \"webkit\"],\n  ...\n}\n```\n\n- You can define custom browser. You can find out use cases [here](https://github.com/playwright-community/jest-playwright/issues/539):\n\n```js\n{\n  // Name of browser\n  name: 'chromium' | 'firefox' | 'webkit'\n  // Display name for test\n  displayName: string\n  ...\n  // Browser options\n}\n```\n\n### Device configuration\n\nThere are different ways to define devices in your configuration file:\n\n- You can use array of device names:\n\n```js\nmodule.exports = {\n  devices: [\"iPhone 6\", \"Pixel 2\"],\n  ...\n}\n```\n\n- You can use **RegExp**:\n\n```js\nmodule.exports = {\n  devices: /iPhone 8/,\n  ...\n}\n```\n\n- Also you can define custom device:\n\n```js\n{\n  // Name of device\n  name: string\n  // Page width and height\n  viewport: {\n    width: number\n    height: number\n  }\n  // user agent\n  userAgent: string\n  // device scale factor\n  deviceScaleFactor: number\n  // is device is mobile\n  isMobile: boolean\n  // support of touch events\n  hasTouch: boolean\n  // device default browser\n  defaultBrowserType: chromium, firefox or webkit\n}\n```\n\n## Globals\n\n- `browserName` \u003c[string]\u003e - name of the current browser (chromium, firefox or webkit)\n- `deviceName` \u003c[string]\u003e - name of the current device\n- `browser` \u003c[[Browser](https://playwright.dev/docs/api/class-browser/)]\u003e - Playwright browser instance\n- `context` \u003c[[Context](https://playwright.dev/docs/api/class-browsercontext/)]\u003e - a new Playwright context instance for each new test file\n- `page` \u003c[[Page](https://playwright.dev/docs/api/class-page/)]\u003e - Playwright page instance (since a new context for every test file also creates a new page for it)\n\nAll of them are available globally in each Jest test. If you are using ESLint and JavaScript, its recommend to use it in combination with the [eslint-plugin-jest-playwright](https://github.com/playwright-community/eslint-plugin-jest-playwright).\n\n## Debug mode\n\nPlaywright give you [ability](https://playwright.dev/docs/debug/#run-in-debug-mode) to configure the browser for debugging with the `PWDEBUG` environment variable. It will launch the browser in headful mode, disables playwright timeout and **Jest** won't timeout anymore.:\n\n```js\nPWDEBUG=1 jest\n```\n\n## Reset helper functions\n\n### Reset current page\n\n```js\nbeforeEach(async () =\u003e {\n  await jestPlaywright.resetPage()\n})\n```\n\nTo create a new page for each test, you can use this snippet to have a new page object for each individual test.\n\n### Reset current context\n\n```js\nbeforeEach(async () =\u003e {\n  await jestPlaywright.resetContext()\n})\n```\n\nTo create a new context for each test, you can use this snippet to have a new context object for each individual test.\n\n### Reset current browser\n\n```js\nbeforeEach(async () =\u003e {\n  await jestPlaywright.resetBrowser()\n})\n```\n\nYou can use this snippet to reset current browser for each individual test. It will reset browser, context and page.\n\n## Debug helper functions\n\n`jest-playwright` provides some functions to debug your tests.\n\n**IMPORTANT NOTE**: For these kind of tests you should use properties passed through callback function instead of [globals](https://github.com/playwright-community/jest-playwright#globals)\n\n### jestPlaywrightDebug\n\nThis helper function provide you ability to run specific tests in `debug` mode. It will disable `headless` mode.\nYou can find more information [here](https://github.com/playwright-community/jest-playwright/issues/216)\n\n```js\ntest.jestPlaywrightDebug('failed', async ({ page }) =\u003e {\n  await page.goto('https://github.com/')\n  const title = await page.title()\n  await expect(title).toBe('Google')\n})\n```\n\nAlso you can define options for `debug` mode with `debugOptions`:\n\n```js\n// jest-playwright.config.js\nmodule.exports = {\n  debugOptions: {\n    ...\n    contextOptions: {\n      offline: true\n    }\n  }\n  ...\n}\n```\n\n### jestPlaywrightConfig\n\nThis helper function provide you ability to run specific tests with passed options.\nYou can define `browser` and `device` properties to run test for them, otherwise test run for current configuration.\n\n```js\ntest.jestPlaywrightConfig(\n  {\n    // your jest-playwright options\n  },\n  'test name',\n  async ({ browser, context, page }) =\u003e {\n    /* ... */\n  },\n)\n```\n\n## Tracking the coverage\n\nIt's possible to track the coverage of the end-to-end tests with the [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul) Babel plugin configured. It needs to be included in the web application which you are gonna test otherwise it won't work. To use it, you have to set `collectCoverage` in the `jest-playwright.config.js` to `true`. Per default the test coverage will be automatically saved after each navigation change (`beforeunload` event). If a certain code path is not covered, you can manually call and add the corresponding `saveCoverage(page)` call to your tests like that:\n\n```js\nawait jestPlaywright.saveCoverage(page)\n```\n\nBy using coverage collection, it will write the coverage data to the `.nyc_output/coverage.json` file which can be transformed using [`nyc`](https://github.com/istanbuljs/nyc#readme) to the lcov format:\n\n```\nnpx nyc report --reporter=lcovonly\n```\n\nor to HTML:\n\n```\nnpx nyc report --reporter=html\n```\n\nwhich will create a HTML website in the `coverage` directory.\n\n## Skip tests for specific browsers and devices\n\nIt's possible to skip tests for browsers or combination of browsers and devices\n\n```js\nit.jestPlaywrightSkip(\n  { browsers: ['chromium'] },\n  'should skip this one',\n  async () =\u003e {\n    const title = await page.title()\n    expect(title).toBe('Google')\n  },\n)\n```\n\n## Using [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM) selectors\n\nPlaywright engine pierces open shadow DOM by [default](https://playwright.dev/docs/selectors?_highlight=shadow#selector-engines).\n\n```js\nbeforeAll(async () =\u003e {\n  await page.goto(\n    'https://mdn.github.io/web-components-examples/popup-info-box-web-component/',\n  )\n})\n\ntest('should display \"google\" text on page', async () =\u003e {\n  const shadowElem = await page.$('.info')\n  const shadowElemText = await shadowElem.innerHTML()\n\n  expect(shadowElemText).toBe(\n    'Your card validation code (CVC) is an extra security feature — it is the last 3 or 4 numbers on the back of your card.',\n  )\n})\n```\n\n## Start a server\n\nJest Playwright integrates a functionality to start a server when running your test suite, like [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer/blob/master/README.md#start-a-server). It automatically closes the server when tests are done.\n\nTo use it, specify a server section in your `jest-playwright.config.js`.\n\n```js\n// jest-playwright.config.js\nmodule.exports = {\n  serverOptions: {\n    command: 'node server.js',\n    port: 4444,\n  },\n}\n```\n\nOther options are documented in [jest-process-manager](https://github.com/playwright-community/jest-process-manager).\n\n## Using with different jest environments\n\nThe default **jest-playwright** environment is **node**, but you can use a browser-like environment through [jest-playwright-jsdom](https://github.com/playwright-community/jest-playwright-jsdom)\n\n## expect-playwright\n\nThere is a utility package [expect-playwright](https://github.com/playwright-community/expect-playwright) which simplifies the expect statements in combination with Playwright to make e.g. shorter text comparisons.\n\n## ESLint globals / `'page' is not defined`\n\nThere is an ESLint plugin available [eslint-plugin-jest-playwright](https://github.com/playwright-community/eslint-plugin-jest-playwright) available which includes the globals for using jest-playwright.\n\n## Unstable and experimental API\n\nYou can run tests for multiple browsers and devices:\n\n- You must have installed the **playwright** package\n- You must define browsers to test with your `jest-playwright.config.js`:\n\n```javascript\nmodule.exports = {\n    browsers: [\"chromium\", \"webkit\"],\n    devices: [\"iPhone 6\", \"Pixel 2\"],\n    ...\n}\n```\n\nIt will run your tests for:\n\n- **Chromium** browser and **iPhone 6** device;\n- **Chromium** browser and **Pixel 2** device;\n- **Webkit** browser and **iPhone 6** device;\n- **Webkit** browser and **Pixel 2** device;\n\nIf there is no defined browsers in config it will run tests for chromium browser.\n\n## Usage with custom [testEnvironment](https://jestjs.io/docs/en/configuration#testenvironment-string)\n\nYou can use **jest-playwright** with custom test environment for taking screenshots during test failures for example:\n\n**jest.config.json**\n\n```json\n\"testEnvironment\": \"./CustomEnvironment.js\"\n```\n\n**CustomEnvironment.js**\n\n```js\nconst PlaywrightEnvironment =\n  require('jest-playwright-preset/lib/PlaywrightEnvironment').default\n\nclass CustomEnvironment extends PlaywrightEnvironment {\n  async setup() {\n    await super.setup()\n    // Your setup\n  }\n\n  async teardown() {\n    // Your teardown\n    await super.teardown()\n  }\n\n  async handleTestEvent(event) {\n    await super.handleTestEvent(event)\n    if (event.name === 'test_done' \u0026\u0026 event.test.errors.length \u003e 0) {\n      const parentName = event.test.parent.name.replace(/\\W/g, '-')\n      const specName = event.test.name.replace(/\\W/g, '-')\n\n      await this.global.page.screenshot({\n        path: `screenshots/${parentName}_${specName}.png`,\n      })\n    }\n  }\n}\n\nmodule.exports = CustomEnvironment\n```\n\n## Usage with custom [runner](https://jestjs.io/docs/en/configuration#runner-string)\n\n**jest-playwright** using custom runner underhood. So if you need implement your own `runner`, you should extend it:\n\n**jest.config.json**\n\n```json\n\"runner\": \"./CustomRunner.js\"\n```\n\n**CustomRunner.js**\n\n```js\nconst PlaywrightRunner =\n  require('jest-playwright-preset/lib/PlaywrightRunner').default\n\nclass CustomRunner extends PlaywrightRunner {\n  constructor(...args) {\n    super(...args)\n    this.isSerial = true\n  }\n}\n\nmodule.exports = CustomRunner\n```\n\n## Usage with custom [`globalSetup`](https://facebook.github.io/jest/docs/en/configuration.html#globalsetup-string) and [`globalTeardown`](https://facebook.github.io/jest/docs/en/configuration.html#globalteardown-string)\n\nFor this use case, `jest-playwright-preset` exposes two methods: `globalSetup` and `globalTeardown`, so that you can wrap them with your own global setup and global teardown methods as the following example:\n\n### Getting authentication state once for all test cases [as per playwright reference](https://playwright.dev/docs/auth?_highlight=globals#reuse-authentication-state):\n\n```js\n// global-setup.js\nimport { globalSetup as playwrightGlobalSetup } from 'jest-playwright-preset'\n\nmodule.exports = async function globalSetup(globalConfig) {\n  await playwrightGlobalSetup(globalConfig)\n\n  const browserServer = await chromium.launchServer()\n  const wsEndpoint = browserServer.wsEndpoint()\n  const browser = await chromium.connect({ wsEndpoint: wsEndpoint })\n  const page = await browser.newPage()\n\n  // your login function\n  await doLogin(page)\n\n  // store authentication data\n  const storage = await page.context().storageState()\n  process.env.STORAGE = JSON.stringify(storage)\n}\n```\n\n```js\n// global-teardown.js\nimport { globalTeardown as playwrightGlobalTeardown } from 'jest-playwright-preset'\n\nmodule.exports = async function globalTeardown(globalConfig) {\n  // Your global teardown\n  await playwrightGlobalTeardown(globalConfig)\n}\n```\n\nThen assigning your js file paths to the [`globalSetup`](https://facebook.github.io/jest/docs/en/configuration.html#globalsetup-string) and [`globalTeardown`](https://facebook.github.io/jest/docs/en/configuration.html#globalteardown-string) property in your Jest configuration.\n\n```js\n{\n  // ...\n  \"globalSetup\": \"./global-setup.js\",\n  \"globalTeardown\": \"./global-teardown.js\"\n}\n```\n\nNow your custom `globalSetup` and `globalTeardown` will be triggered once before and after all test suites.\n\n## Usage with Typescript\n\nExample Jest configuration in combination with [ts-jest](https://github.com/kulshekhar/ts-jest):\n\n```javascript\nmodule.exports = {\n  preset: 'jest-playwright-preset',\n  transform: {\n    '^.+\\\\.ts$': 'ts-jest',\n  },\n}\n```\n\nTypes are also available, which you can either use via directly in your test:\n\n```typescript\n/// \u003creference types=\"jest-playwright-preset\" /\u003e\n/// \u003creference types=\"expect-playwright\" /\u003e\n```\n\nor at your central `tsconfig.json` either via `files`:\n\n```json\n{\n  \"files\": [\n    \"./global.d.ts\",\n    \"node_modules/jest-playwright-preset/types/global.d.ts\",\n    \"node_modules/expect-playwright/global.d.ts\"\n  ]\n}\n```\n\nor via `types`:\n\n```json\n{\n  \"compilerOptions\": {\n    \"types\": [\"jest-playwright-preset\", \"expect-playwright\"]\n  }\n}\n```\n\nIt's important to not change the `testEnvironment` to `node`. Otherwise it won't work.\n\n## Known issues\n\n### Error reporting with Jest\n\nIf you face into error messages like\n\n```\nUnhandledPromiseRejectionWarning: Error: Protocol error (Runtime.callFunctionOn): Target closed.\n```\n\nor\n\n```\nTimeout - Async callback was not invoked within the 20000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 20000ms timeout specified by jest.setTimeout.Error:\n```\n\nand your Jest error reporting will only show that an entire test (`it()` function) has failed, then you need to increase the Jest timeout because the Playwright timeout is greater than the Jest timeout. So Jest in the end will simply stop the execution and no verbose (which exact line) error reporting can be generated.\n\nTo fix this behavior simply call\n\n```javascript\njest.setTimeout(35 * 1000)\n```\n\nin your tests at the top. (30 seconds is the default Playwright timeout for waiting for an specific element.)\n\n### New Browser instance for each test\n\nIf for your individual tests a new entire browser instance spins up each time and it won't be reused, then you probably run them in parallel. If you run them in a synchronous way with the `--runInBand` CLI option for Jest, then the same browser instance will be re-used and this should fix the issue.\n\n## Examples\n\nDemonstration the usage of `jest-playwright` for various test cases can be found in [`playwright-jest-examples`](https://github.com/playwright-community/playwright-jest-examples)\n\n## Inspiration\n\nThanks to [Smooth Code](https://github.com/smooth-code) for the great [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer).\n\n## License\n\n[MIT](https://github.com/playwright-community/jest-playwright/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaywright-community%2Fjest-playwright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplaywright-community%2Fjest-playwright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplaywright-community%2Fjest-playwright/lists"}