From 940a36fd650f769add76037037197a2b22b19e3f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 3 Feb 2019 10:06:01 +0330 Subject: [PATCH] chore: use puppeteer-core (#4929) --- .circleci/config.yml | 2 -- package.json | 5 +++-- test/utils/browser.js | 27 +++++++++++++++++---------- yarn.lock | 8 ++++---- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 35c04eb206..436dc9e06b 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -147,8 +147,6 @@ jobs: test-types: <<: *defaults - docker: - - image: circleci/node:latest-browsers steps: - checkout - attach_workspace: diff --git a/package.json b/package.json index 1629da20f6..64092399ab 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "node-fetch": "^2.3.0", "pug": "^2.0.3", "pug-plain-loader": "^1.0.0", - "puppeteer": "~1.11.0", + "puppeteer-core": "^1.12.1", "request": "^2.88.0", "request-promise-native": "^1.0.5", "rimraf": "^2.6.3", @@ -80,7 +80,8 @@ "tslint": "^5.12.1", "typescript": "^3.3.1", "vue-jest": "^3.0.2", - "vue-property-decorator": "^7.3.0" + "vue-property-decorator": "^7.3.0", + "which": "^1.3.1" }, "repository": { "type": "git", diff --git a/test/utils/browser.js b/test/utils/browser.js index 9cfedec129..ca5aa9afd1 100644 --- a/test/utils/browser.js +++ b/test/utils/browser.js @@ -1,17 +1,24 @@ -import puppeteer from 'puppeteer' +import puppeteer from 'puppeteer-core' +import which from 'which' export default class Browser { async start(options = {}) { // https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions - this.browser = await puppeteer.launch( - Object.assign( - { - args: ['--no-sandbox', '--disable-setuid-sandbox'], - executablePath: process.env.PUPPETEER_EXECUTABLE_PATH - }, - options - ) - ) + const _opts = { + args: [ + '--no-sandbox', + '--disable-setuid-sandbox' + ], + executablePath: process.env.PUPPETEER_EXECUTABLE_PATH, + ...options + } + + if (!_opts.executablePath) { + const resolve = cmd => which.sync(cmd, { nothrow: true }) + _opts.executablePath = resolve('google-chrome') || resolve('chromium') + } + + this.browser = await puppeteer.launch(_opts) } async close() { diff --git a/yarn.lock b/yarn.lock index 02e409d5d9..8d7b51c695 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9231,10 +9231,10 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -puppeteer@~1.11.0: - version "1.11.0" - resolved "https://registry.npmjs.org/puppeteer/-/puppeteer-1.11.0.tgz#63cdbe12b07275cd6e0b94bce41f3fcb20305770" - integrity sha512-iG4iMOHixc2EpzqRV+pv7o3GgmU2dNYEMkvKwSaQO/vMZURakwSOn/EYJ6OIRFYOque1qorzIBvrytPIQB3YzQ== +puppeteer-core@^1.12.1: + version "1.12.1" + resolved "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-1.12.1.tgz#aec39d9c199ceff6ddd4da00e0733bb73fce4156" + integrity sha512-arGXPRe1dkX3+tOh1GMQ0Ny3CoOCRurkHAW4AZEBIBMX/LdY6ReFqRTT9YSV3d9zzxiIat9kJc3v9h9nkxAu3g== dependencies: debug "^4.1.0" extract-zip "^1.6.6"