Skip to content

V8 coverage is 0% with jsdom environment on Windows #31842

@jurinmaxim

Description

@jurinmaxim

Command

test

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Coverage summary shows 0% when running tests with Vitest (environment: jsdom) and V8 coverage provider on version 21.0.0-rc.4. Works correctly with browser environments (e.g., playwright). This problem occurs only on Windows. I haven't encountered this issue in CI pipelines using the official nodejs docker image, nor on other Linux-based operating systems.
Expected behavior: coverage should work with jsdom without requiring a browser.

Minimal Reproduction

Steps to reproduce (see attached minimal reproduction):

  1. Create project: npx @angular/[email protected] new coverage-v8-jsdom
  2. Add coverage provider: npm i -D @vitest/coverage-v8
  3. Update angular.json test options:
"options": {
  "coverage": true
}
  1. Run tests: npm run test
    The coverage summary will show 0 for all statements, branches, etc.

  2. Add browser support: npm i -D @vitest/browser-playwright

  3. Update test options in angular.json:

"options": {
 "browsers": ["ChromiumHeadless"],
  ...
}
  1. Run tests again: npm run test
    The coverage summary will correctly show the coverage.

Note: The attached minimal reproduction should work after npm install and npm run test. If you remove the browsers option from angular.json, coverage will again be incorrect.

coverage-v8-jsdom.zip

Exception or Error


Your Environment

Angular CLI       : 21.0.0-rc.4
Angular           : 21.0.0-rc.2
Node.js           : 22.16.0
Package Manager   : npm 10.9.2
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.0.0-rc.4       │ ^21.0.0-rc.4      │
│ @angular/cli              │ 21.0.0-rc.4       │ ^21.0.0-rc.4      │
│ @angular/common           │ 21.0.0-rc.2       │ ^21.0.0-next.0    │
│ @angular/compiler         │ 21.0.0-rc.2       │ ^21.0.0-next.0    │
│ @angular/compiler-cli     │ 21.0.0-rc.2       │ ^21.0.0-next.0    │
│ @angular/core             │ 21.0.0-rc.2       │ ^21.0.0-next.0    │
│ @angular/forms            │ 21.0.0-rc.2       │ ^21.0.0-next.0    │
│ @angular/platform-browser │ 21.0.0-rc.2       │ ^21.0.0-next.0    │
│ @angular/router           │ 21.0.0-rc.2       │ ^21.0.0-next.0    │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.0.9             │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions