Skip to content

Commit

Permalink
fix: require to puppeteer-core as fallback (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwu823 authored Feb 16, 2020
1 parent 655d37c commit 49d313c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/jest-environment-puppeteer/src/readConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ export async function readConfig() {

export function getPuppeteer(config) {
switch (config.browser.toLowerCase()) {
/* eslint-disable global-require, import/no-dynamic-require, import/no-extraneous-dependencies, import/no-unresolved */
case 'chromium':
// eslint-disable-next-line global-require, import/no-dynamic-require, import/no-extraneous-dependencies
return require('puppeteer')
try {
return require('puppeteer')
} catch (e) {
return require('puppeteer-core')
}
case 'firefox':
// eslint-disable-next-line global-require, import/no-dynamic-require, import/no-extraneous-dependencies
return require('puppeteer-firefox')
/* eslint-enable */
default:
throw new Error(
`Error: "browser" config option is given an unsupported value: ${browser}`,
Expand Down

0 comments on commit 49d313c

Please sign in to comment.