Skip to content

Coverage only works with Chromium in vitest #32950

@JakobDev

Description

@JakobDev

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

If you use browser based testing with vitest and enable testcoverage by setting coverage to true as described in the documentation, the tests will now only work on Chromium. Testing on all other browsers will fail with Error: browserContext.newCDPSession: CDP session is only available in Chromium.

Here is a little example project

Just run npm run test-chromium to test with Chromium, which will work and npm run test-firefox to test with Firefox, which will fail.

If you disable coverage in the angular.json, Firefox will work.

So unlike with Karma, it's no loner possible to run tests with multiple Browsers and Coverage enabled.

An alternative is to add the --coverage flag to test-chromium, but with this setup I need to add a command for each browser and can't use the browsers array in the angular.json.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)

Angular CLI       : 21.2.6
Angular           : 21.2.7
Node.js           : 24.6.0
Package Manager   : npm 11.12.1
Operating System  : darwin arm64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.2.6            │ ^21.2.1           │
│ @angular/cli              │ 21.2.6            │ ^21.2.1           │
│ @angular/common           │ 21.2.7            │ ^21.2.0           │
│ @angular/compiler         │ 21.2.7            │ ^21.2.0           │
│ @angular/compiler-cli     │ 21.2.7            │ ^21.2.0           │
│ @angular/core             │ 21.2.7            │ ^21.2.0           │
│ @angular/forms            │ 21.2.7            │ ^21.2.0           │
│ @angular/platform-browser │ 21.2.7            │ ^21.2.0           │
│ @angular/router           │ 21.2.7            │ ^21.2.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.1.3             │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions