From 2c763df176930509c178cbc79b654e083cc5fc84 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 7 Feb 2019 20:18:47 +0330 Subject: [PATCH] test: fix macos e2e tests --- test/utils/browser.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/utils/browser.js b/test/utils/browser.js index ca5aa9afd1..76b2c4cd9f 100644 --- a/test/utils/browser.js +++ b/test/utils/browser.js @@ -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 = {}) { @@ -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)