question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chromeheadless not captured inside a windows container

See original GitHub issue

So 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:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
andyfisher100commented, May 15, 2019

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

  • Arial
  • Consola
  • times new roman (saved as “times.ttf”)

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)

1reaction
prom3theu5commented, May 17, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

"ChromeHeadless have not captured in 60000 ms, killing ...
I am expecting the tests to run successfully in all three instances (local npm, local Gitlab Runner and remote Gitlab CI/CD pipeline). Currently ......
Read more >
zenika/alpine-chrome - Docker Image
3 ways to securely use Chrome Headless with this image. ❌ With nothing. Launching the container using only docker container run -it zenika/alpine-chrome ......
Read more >
Run Angular Unit Tests in Gitlab CI - Telstra Purple
Unit testing brings many benefits to our projects by assuring that code mistakes could be captured early and not in the production.
Read more >
Untitled
To run our Selenium test in Chrome headless, Selenium gives a class called ... does not work on Windows 10 when using headless...
Read more >
Things to consider when running visual tests in CI/CD pipelines
In a world where DevOps is more than just a buzzword, ... container (newer, more cloud native, no direct access to local chrome; ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found