test: disable Chrome sandboxing when inside Docker
See the discussion in https://github.com/docker/for-linux/issues/496 Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
This commit is contained in:
parent
cceb8a3c26
commit
8311138f3e
|
@ -104,7 +104,7 @@ module.exports = function(grunt) {
|
|||
karma: {
|
||||
'unit-once': {
|
||||
configFile: 'test/karma.conf.js',
|
||||
browsers: ['ChromeHeadless'],
|
||||
browsers: ['ChromeDocker'],
|
||||
singleRun: true,
|
||||
reporters: ['dots', 'junit'],
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
"grunt-eslint": "^21.0.0",
|
||||
"grunt-karma": "^3.0.2",
|
||||
"grunt-mocha-test": "^0.13.3",
|
||||
"is-docker": "^2.0.0",
|
||||
"karma": "^4.1.0",
|
||||
"karma-browserify": "^6.0.0",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
|
|
|
@ -3,12 +3,31 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
'use strict';
|
||||
|
||||
const isDocker = require('is-docker');
|
||||
|
||||
// Karma configuration
|
||||
// http://karma-runner.github.io/0.12/config/configuration-file.html
|
||||
|
||||
'use strict';
|
||||
module.exports = function(config) {
|
||||
// see https://github.com/docker/for-linux/issues/496
|
||||
const disableChromeSandbox = isDocker() && !process.env.TRAVIS;
|
||||
if (disableChromeSandbox) {
|
||||
console.log('!! Disabling Chrome sandbox to support un-privileged Docker !!');
|
||||
}
|
||||
|
||||
config.set({
|
||||
customLaunchers: {
|
||||
ChromeDocker: {
|
||||
base: '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
|
||||
flags: disableChromeSandbox ? ['--no-sandbox'] : [],
|
||||
},
|
||||
},
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: true,
|
||||
|
||||
|
|
Loading…
Reference in New Issue