Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jest-environment-puppeteer): added config option for global err msg #35

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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