ChromeHeadless running with docker
See original GitHub issueGetting a timeout error when running ChromeHeadless with karma inside a docker container. This is an Angular cli project with angular 6 with karma 3.0. We run Karma through a makefile script that uses docker-compose. Here’s the Karma config file.
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function(config) {
var host = process.env.HOST_IP || process.env.HOSTNAME;
config.set({
basePath: '',
mime: {
"text/x-typescript": ["ts", "tsx"]
},
frameworks: ['parallel', 'jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-junit-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-parallel')
],
parallelOptions: {
executors: Math.ceil(require('os').cpus().length / 2),
shardStrategy: 'round-robin'
},
client: {
jasmine: {
random: false // Don't run tests in random order
}
},
customLaunchers: {
Chrome_no_sandbox: {
base: 'Chrome',
flags: [
'--headless',
'--disable-web-security',
'--disable-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
'--remote-debugging-port=xxxx',
'--remote-debugging-address=xxx.x.x.x'
]
}
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'),
reports: ['html', 'lcovonly', 'cobertura'],
fixWebpackSourcePaths: true
},
// the default configuration
junitReporter: {
outputDir: './test-results', // results will be saved as $outputDir/$browserName.xml
outputFile: 'test-results.xml', // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: '', // suite will become the package name attribute in xml testsuite element
useBrowserName: false, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {} // key value pair of properties to add to the <properties> section of the report
},
reporters:
config.buildWebpack &&
config.buildWebpack.options &&
config.buildWebpack.options.codeCoverage
? ['progress', 'coverage-istanbul', 'junit']
: ['progress', 'kjhtml'],
hostname: host,
port: process.env.KARMA_PORT,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false,
captureTimeout: 100000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 1,
browserNoActivityTimeout: 100000
});
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to run google chrome headless in docker? - Stack Overflow
My first approach is to use xvbf , but the process is more simple when used --headless flag.
Read more >yukinying/chrome-headless-browser-docker - GitHub
This docker image contains the Linux Dev channel Chromium (https://www.chromium.org/getting-involved/dev-channel), with the required dependencies and the ...
Read more >justinribeiro/chrome-headless - Docker Image
Container for use of --headless flag in Google Chrome. Stable / Beta / Dev channels available.
Read more >How to set up a Headless Chrome Node.js server in Docker
Setting up a browser to run inside a container can help boost flexibility and scalability. Here's how to set up a headless Chrome...
Read more >Crafting the perfect container to play with a Headless Chrome
Tagged with opensource, docker, testing, javascript. ... on this project to create the perfect image to run Chromium in Headless mode:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think your issue is that what you have in the
browsers
option (ChromeHeadless) doesn’t match with what you have incustomLaunchers
(Chrome_no_sandbox).Have set it up mine this way and works for me:
Dockerfile:
Then in karma.conf.js:
It seems the main missing part in the configuration is
--no-sandbox
. This flag is required when using Chrome inside Docker. See also https://github.com/karma-runner/karma-chrome-launcher/issues/158 and https://docs.travis-ci.com/user/chrome#sandboxing.