From c7d818f3dbac7865b5de14e98782442a8756f117 Mon Sep 17 00:00:00 2001 From: iapyang Date: Tue, 14 Apr 2020 16:28:54 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=8D=95=E6=B5=8B=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmrc | 1 + karma.conf.js | 33 +++++++++++++++++++++++++++++++-- package.json | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..251921610 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +PUPPETEER_DOWNLOAD_HOST = https://npm.taobao.org/mirrors \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 51b6bf4be..cdeb3baad 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,5 +1,10 @@ // Karma configuration // Generated on Mon Nov 27 2017 11:16:26 GMT+0800 (中国标准时间) + +const os = require("os"); + +process.env.CHROME_BIN = require("puppeteer").executablePath(); + module.exports = function (config) { config.set({ @@ -114,10 +119,34 @@ module.exports = function (config) { autoWatch: true, + customLaunchers: { + HeadlessChrome: { + base: "ChromeHeadless", + flags: [ + "--no-sandbox", + "--remote-debugging-port=9222", + "--enable-logging", + "--user-data-dir=./karma-chrome", + "--v=1", + "--disable-background-timer-throttling", + "--disable-renderer-backgrounding", + "--proxy-bypass-list=*", + "--disable-web-security", + "--disable-gpu", + "--no-sandbox", + ], + }, + }, + + // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - // browsers: [isJenkins ? "Chrome" : "ChromeHeadless"], - browsers: ["Chrome"], + browsers: [os.platform() === "win32" + && parseFloat(os.release() + .split(".") + .slice(0, 2) + .join(".")) <= 6.1 + ? "HeadlessChrome" : "ChromeHeadless"], retryLimit: 30, diff --git a/package.json b/package.json index 19b0cd379..d5f55b3a2 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "optimize-css-assets-webpack-plugin": "5.0.3", "postcss-loader": "3.0.0", "postcss-simple-vars": "5.0.2", + "puppeteer": "2.1.0", "source-map-loader": "0.2.4", "style-loader": "0.23.1", "typescript": "3.5.2",