From 387835faeff01888a734de166892f8906ce09be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Tue, 1 Oct 2019 08:12:52 +0200 Subject: [PATCH] test: use Chromium (not Chrome) when available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- package.json | 3 ++- test/karma.conf.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a98f9c80..f51d1c3b 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,8 @@ "sinon-chai": "^3.2.0", "strong-error-handler": "^3.0.0", "strong-task-emitter": "^0.0.8", - "supertest": "^3.0.0" + "supertest": "^3.0.0", + "which": "^1.3.1" }, "repository": { "type": "git", diff --git a/test/karma.conf.js b/test/karma.conf.js index 6b0c0fd5..d3785a0d 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -6,6 +6,7 @@ 'use strict'; const isDocker = require('is-docker'); +const which = require('which'); // Karma configuration // http://karma-runner.github.io/0.12/config/configuration-file.html @@ -17,10 +18,15 @@ module.exports = function(config) { console.log('!! Disabling Chrome sandbox to support un-privileged Docker !!'); } + const hasChromium = + which.sync('chromium-browser', {nothrow: true}) || + which.sync('chromium', {nothrow: true}); + config.set({ customLaunchers: { ChromeDocker: { - base: 'ChromeHeadless', + // cis-jenkins build server does not provide Chrome, only Chromium + base: hasChromium ? 'ChromiumHeadless' : 'ChromeHeadless', // We must disable the Chrome sandbox when running Chrome inside Docker // (Chrome's sandbox needs more permissions than Docker allows by default) // See https://github.com/docker/for-linux/issues/496