Skip to content

Commit

Permalink
feat(jest-environment-puppeteer): added config option for global err …
Browse files Browse the repository at this point in the history
…msg (#35)

Closes #34
  • Loading branch information
kaufmann42 authored and gregberge committed Apr 11, 2018
1 parent 55920c7 commit d87c99a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/jest-environment-puppeteer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ it('should fill an input', async () => {
You can specify a `jest-puppeteer.config.js` at the root of the project or define a custom path using `JEST_PUPPETEER_CONFIG` environment variable.

* `launch` <[object]> [All Puppeteer launch options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions) can be specified in config. Since it is JavaScript, you can use all stuff you need, including environment.
* `exitOnPageError` <[boolean]> Exits page on any global error message thrown. Defaults to `true`.
* `server` <[Object]> Server options
* `command` <[string]> Command to start server
* `port` <[number]> If specified, it will wait port to be listened
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class PuppeteerEnvironment extends NodeEnvironment {
browserWSEndpoint: wsEndpoint,
})
this.global.page = await this.global.browser.newPage()
this.global.page.addListener('pageerror', handleError)
if (config && config.exitOnPageError) {
this.global.page.addListener('pageerror', handleError)
}
}

async teardown() {
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-environment-puppeteer/src/readConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ const exists = promisify(fs.exists)

const DEFAULT_CONFIG = {
launch: {},
exitOnPageError: true
}
const DEFAULT_CONFIG_CI = {
launch: {
args: ['--no-sandbox', '--disable-setuid-sandbox'],
},
exitOnPageError: true
}

async function readConfig() {
Expand Down

0 comments on commit d87c99a

Please sign in to comment.