Skip to content

Commit

Permalink
feat(expect-puppeteer): Simplify getBrowser function
Browse files Browse the repository at this point in the history
  • Loading branch information
gidztech committed Aug 19, 2018
1 parent db05a3c commit c1ee05e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/jest-environment-puppeteer/src/PuppeteerEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,15 @@ const handleError = error => {

const getBrowser = async config => {
const wsEndpoint = fs.readFileSync(WS_ENDPOINT_PATH, 'utf8')
let slowMo
let ignoreHTTPSErrors

if (!wsEndpoint) {
throw new Error('wsEndpoint not found')
}

if (config) {
slowMo = (config.connect && config.connect.slowMo) || (config.launch && config.launch.slowMo)
ignoreHTTPSErrors = (config.connect && config.connect.ignoreHTTPSErrors) || (config.launch && config.launch.ignoreHTTPSErrors)
}

return puppeteer.connect({
slowMo,
ignoreHTTPSErrors,
browserWSEndpoint: wsEndpoint,
...config.connect,
...config.launch,
browserWSEndpoint: wsEndpoint
})
}

Expand Down

0 comments on commit c1ee05e

Please sign in to comment.