From 4af5a863a57b53020fd551ea480d94ddbd81d2f4 Mon Sep 17 00:00:00 2001 From: Thomas Wang Date: Thu, 20 Feb 2020 20:08:45 -0800 Subject: [PATCH] Use headless Chrome in ci --- .travis.yml | 18 ++++-------------- karma.conf.js | 11 +++++++++-- package.json | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0061e0..b5d811c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,11 @@ -sudo: false language: node_js node_js: - "12" -before_install: - - "npm config set spin false" - # if npm version is less than 3.0.0, upgrade to 3 - - if [[ $(npm -v | cut -d '.' -f 1) -lt 3 ]]; then npm i -g npm@^3; fi - - "npm config set spin false" - -script: npm run test-ci -install: - - node --version - - npm --version - - git --version - - npm install +addons: + chrome: stable +script: yarn run test-ci after_script: - - find ./coverage/Phantom* -name "lcov.info" -exec cat {} \; | coveralls + - find ./coverage/HeadlessChrome* -name "lcov.info" -exec cat {} \; | coveralls diff --git a/karma.conf.js b/karma.conf.js index bcdf824..d8b803a 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -61,8 +61,15 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['Chrome'], - + browsers: ['Chrome', 'ChromeHeadless', 'ChromeHeadlessNoSandbox'], + + // you can define custom flags + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: 'ChromeHeadless', + flags: ['--no-sandbox'] + } + }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits diff --git a/package.json b/package.json index e132259..20e25ef 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test": "npm run lint && npm run eslint && npm run tests-only", "test-ci": "npm run build && npm run lint && npm run eslint && npm run tests-only-ci", "tests-only": "karma start --single-run", - "tests-only-ci": "karma start --single-run --browsers PhantomJS", + "tests-only-ci": "karma start --single-run --browsers ChromeHeadlessNoSandbox", "lint": "jshint test", "eslint": "eslint src/**/*.ts test", "test:server": "karma start --no-single-run"