Skip to content

ng test fails to detect headless Chrome on first attempt #20449

@acohenOT

Description

@acohenOT

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Unknown

Description

Using karama to run tests with headless Chrome, the first attempt to start Chrome apparently goes undetected. It eventually times out, kills the process, then starts Chrome again and is able to continue with the tests. This causes an unnecessary 2+ minute delay. The Chrome process starts successfully but for some reason it's not detecting it until the 2nd attempt.

🔬 Minimal Reproduction

  1. Create new application:
    ng new <app-name> --strict=true --style=scss --routing=true
  2. Install @progress/kendo-theme-default
    npm install @progress/kendo-theme-default --save
  3. Open styles.scss, add the following line:
    @import "~@progress/kendo-theme-default/scss/all";
  4. Open karma.conf.js and change the following properties:
    autoWatch: false
    browsers: ['ChromeHeadlessCI'],
    customLaunchers: {
      ChromeHeadlessCI: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox']
      }
    },
   singleRun: true
  1. Run ng test

After 2+ minutes, warning in console shows: WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
Then, NFO [launcher]: Trying to start ChromeHeadless again (1/2).
The second time launches without issue.

If you remove the line from styles.scss and repeat ng test, the problem is not visible.

Alternatively, check out this repo and run ng test: https://github.com/acohenOT/unit-testing

🔥 Exception or Error




Karma v6.1.2 server started at http://localhost:9876/
05 04 2021 12:20:05.510:INFO [launcher]: Launching browsers ChromeHeadlessCI with concurrency unlimited
05 04 2021 12:20:05.536:INFO [launcher]: Starting browser ChromeHeadless
- Generating browser application bundles (phase: building)...05 04 2021 12:22:32.075:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
/ Generating browser application bundles (phase: building)...05 04 2021 12:22:32.986:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
√ Browser application bundle generation complete.
05 04 2021 12:22:39.009:INFO [Chrome Headless 89.0.4389.114 (Windows 10)]: Connected on socket 6ClQVkn2c_tOxxhlAAAB with id 89607273
Chrome Headless 89.0.4389.114 (Windows 10): Executed 3 of 3 SUCCESS (0.305 secs / 0.217 secs)
TOTAL: 3 SUCCESS

🌍 Your Environment




Angular CLI: 11.2.7
Node: 14.16.0
OS: win32 x64

Angular: 11.2.8
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.7
@angular-devkit/build-angular   0.1102.7
@angular-devkit/core            11.2.7
@angular-devkit/schematics      11.2.7
@angular/cli                    11.2.7
@schematics/angular             11.2.7
@schematics/update              0.1102.7
rxjs                            6.6.7
typescript                      4.1.5

Anything else relevant?

Chrome Version 89.0.4389.114 (Official Build) (64-bit) for Windows

Only tested on Windows. Unsure if it happens on other OSs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions