Chromeheadless not captured inside a windows container
See original GitHub issueSo i have a windows docker container that works as a build agent for AzureDevOps, formally VSTS.
When running Karma Jasmine tests, either via ADO or manually via the command line, Karma launches chrome but never connects. I know the process has launched as using Get_Process from powershell shows the process running and also when Karma tries the second time the Process IDs all change
Tried running with the no sandbox flag and also fails. Any ideas?
Versions: “karma”: “1.7.0”, “karma-chrome-launcher”: “2.1.1”, “karma-cli”: “1.0.1”, “karma-coverage-istanbul-reporter”: “1.2.1”, “karma-jasmine”: “1.1.0”, “karma-jasmine-html-reporter”: “0.2.2”, “karma-trx-reporter”: “0.2.9”,
Karma Conf
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-trx-reporter')
],
files: [
'test-mocks/mock.js',
'test-mocks/mock.css'
],
proxies: {
"/test-mocks/": "/base/test-mocks/"
},
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'), reports: ['html', 'cobertura'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml', 'trx'],
trxReporter: {
outputFile: 'test-results.trx',
shortTestName: false
},
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox'
]
}
},
browserDisconnectTolerance: 2,
browserDisconnectTimeout: 180000,
browserNoActivityTimeout: 180000,
singleRun: true
});
};
Debug Output [plugin]: Loading inlined plugin (defining framework:jasmine). [plugin]: Loading inlined plugin (defining launcher:Chrome, launcher:ChromeHeadless, launcher:ChromeCanary, launcher:ChromeCanaryHeadless, launcher:Chromium, launcher:Dartium, test). [plugin]: Loading inlined plugin (defining reporter:kjhtml). [plugin]: Loading inlined plugin (defining reporter:coverage-istanbul). [plugin]: Loading inlined plugin (defining framework:@angular-devkit/build-angular, reporter:@angular-devkit/build-angular--sourcemap-reporter, reporter:@angular-devkit/build-angular--event-reporter, middleware:@angular-devkit/build-angular--blocker, middleware:@angular-devkit/build-angular--fallback). [plugin]: Loading inlined plugin (defining reporter:trx). [plugin]: Loading inlined plugin (defining launcher:ChromeHeadlessNoSandbox). 10% building modules 1/1 modules 0 active15 02 2019 02:01:31.210:DEBUG [web-server]: Instantiating middleware [reporter]: Trying to load reporter: @angular-devkit/build-angular--sourcemap-reporter [reporter]: Trying to load color-version of reporter: @angular-devkit/build-angular--sourcemap-reporter (@angular-devkit/build-angular--sourcemap-reporter_color) [reporter]: Couldn’t load color-version. [reporter]: Trying to load reporter: @angular-devkit/build-angular--event-reporter [reporter]: Trying to load color-version of reporter: @angular-devkit/build-angular--event-reporter (@angular-devkit/build-angular--event-reporter_color) [reporter]: Couldn’t load color-version. [reporter]: Trying to load reporter: kjhtml [reporter]: Trying to load color-version of reporter: kjhtml (kjhtml_color) [reporter]: Couldn’t load color-version. [reporter]: Trying to load reporter: trx [reporter]: Trying to load color-version of reporter: trx (trx_color) [reporter]: Couldn’t load color-version. [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/ [launcher]: Launching browser ChromeHeadlessNoSandbox with unlimited concurrency [launcher]: Starting browser ChromeHeadless [temp-dir]: Creating temp dir at C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\karma-82484357 [launcher]: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\karma-82484357 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications --no-sandbox http://localhost:9876/?id=82484357 --headless --disable-gpu --remote-debugging-port=9222 [web-server]: serving: C:\BuildAgent_work\1\s\node_modules\karma\static/client.html [web-server]: serving: C:\BuildAgent_work\1\s\node_modules\karma\static/karma.js [launcher]: ChromeHeadless have not captured in 60000 ms, killing. [launcher]: Process ChromeHeadless exited with code 0 [temp-dir]: Cleaning temp dir C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\karma-82484357 [launcher]: Trying to start ChromeHeadless again (1/2).
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top GitHub Comments
@prom3theu5 Yes i found a workaround for this. I had to add some fonts from my windows dev box to the windows container image. yes really Font files! I did this during docker build. I think this was to do with the default fonts for chrome not being available.
I added all of the variations of the following font files (bold, italics, etc.)
Once all of these fonts where added, i also added the --no-sandbox flag to the karma config for chromeheadless and karma and the tests worked as expected (as shown in the config i originally posted)
@Smenus Yes, I am using ServerCore 2019
I’ve used a powershell script to install the fonts required Put it together Here for you as a simple dockerfile.