Skip to content

Commit

Permalink
test: fix macos e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 7, 2019
1 parent 574a2eb commit 2c763df
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/utils/browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import fs from 'fs'
import puppeteer from 'puppeteer-core'
import which from 'which'
import env from 'std-env'

const macChromePath = [
'/Applications/Chromium.app/Contents/MacOS/Chromium',
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
]

export default class Browser {
async start(options = {}) {
Expand All @@ -16,6 +23,14 @@ export default class Browser {
if (!_opts.executablePath) {
const resolve = cmd => which.sync(cmd, { nothrow: true })
_opts.executablePath = resolve('google-chrome') || resolve('chromium')
if (!_opts.executablePath && env.darwin) {
for (const bin of macChromePath) {
if (fs.existsSync(bin)) {
_opts.executablePath = bin
break
}
}
}
}

this.browser = await puppeteer.launch(_opts)
Expand Down

0 comments on commit 2c763df

Please sign in to comment.