Skip to content

Commit

Permalink
test: disable Chrome sandboxing when running in Docker
Browse files Browse the repository at this point in the history
See the discussion in
docker/for-linux#496

Signed-off-by: Miroslav Bajtoš <[email protected]>
  • Loading branch information
bajtos committed Sep 30, 2019
1 parent 97cfd3c commit 39ab65a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 19 additions & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,30 @@
// 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) {
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,

Expand Down

0 comments on commit 39ab65a

Please sign in to comment.