Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 8ad11b9

Browse files
author
Steve Davis
authored
fix: wire up exitOnPageError config option (#108)
1 parent 8ce19bc commit 8ad11b9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ You can specify a `jest-playwright.config.js` at the root of the project or defi
8080
- `firefox` Each test runs Firefox.
8181
- `webkit` Each test runs Webkit.
8282
- `device` <[string]>. Define a [device](https://github.com/microsoft/playwright/blob/master/docs/api.md#browsertypedevices) to run tests into. Actual list of devices can be found [here](https://github.com/Microsoft/playwright/blob/master/src/deviceDescriptors.ts)
83-
- `exitOnPageError` <[boolean]> Exits page on any global error message thrown. Defaults to `true`.
83+
- `exitOnPageError` <[boolean]> Exits process on any page error. Defaults to `true`.
8484
- `server` <[object]> [All `jest-dev-server` options](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server#options)
8585
- `selectors` <[array]>. Define [selector](https://github.com/microsoft/playwright/blob/v0.11.1/docs/api.md#class-selectors). Each selector must be an object with name and script properties.
8686

src/PlaywrightEnvironment.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class PlaywrightEnvironment extends NodeEnvironment {
9292
const config = await readConfig(this._config.rootDir)
9393
const browserType = getBrowserType(config)
9494
checkBrowserEnv(browserType)
95-
const { context, server, selectors } = config
95+
const { context, exitOnPageError, server, selectors } = config
9696
const device = getDeviceType(config)
9797
const playwrightInstance = await getPlaywrightInstance(
9898
browserType,
@@ -106,7 +106,7 @@ class PlaywrightEnvironment extends NodeEnvironment {
106106
const { setup, ERROR_TIMEOUT, ERROR_NO_COMMAND } = devServer
107107
teardownServer = devServer.teardown
108108
try {
109-
await setup(config.server)
109+
await setup(server)
110110
} catch (error) {
111111
if (error.code === ERROR_TIMEOUT) {
112112
logMessage({
@@ -133,7 +133,9 @@ class PlaywrightEnvironment extends NodeEnvironment {
133133
this.global.browser = await getBrowserPerProcess(playwrightInstance, config)
134134
this.global.context = await this.global.browser.newContext(contextOptions)
135135
this.global.page = await this.global.context.newPage()
136-
this.global.page.on('pageerror', handleError)
136+
if (exitOnPageError) {
137+
this.global.page.on('pageerror', handleError)
138+
}
137139
this.global.jestPlaywright = {
138140
debug: async (): Promise<void> => {
139141
// Run a debugger (in case Playwright has been launched with `{ devtools: true }`)

0 commit comments

Comments
 (0)