test: use Chromium (not Chrome) when available

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
This commit is contained in:
Miroslav Bajtoš 2019-10-01 08:12:52 +02:00
parent 8311138f3e
commit 387835faef
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
2 changed files with 9 additions and 2 deletions

View File

@ -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",

View File

@ -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