Title: V8 Coverage showing unexpected results · Issue #32836 · angular/angular-cli · GitHub
Open Graph Title: V8 Coverage showing unexpected results · Issue #32836 · angular/angular-cli
X Title: V8 Coverage showing unexpected results · Issue #32836 · angular/angular-cli
Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description I'm in the process of migrating from jasmine/karma with istanbul coverage to vitest with v8 coverage. I'm currently migrating...
Open Graph Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description I'm in the process of migrating from jasmine/karma with istanbul coverage to vitest w...
X Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description I'm in the process of migrating from jasmine/karma with istanbul coverage to ...
Opengraph URL: https://github.com/angular/angular-cli/issues/32836
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"V8 Coverage showing unexpected results","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nDon't known / other\n\n### Is this a regression?\n\nNo\n\n### Description\n\nI'm in the process of migrating from jasmine/karma with istanbul coverage to vitest with v8 coverage. I'm currently migrating around 2500 unit tests. With Istanbul I had over 95% coverage across statements, branches, functions and lines. With vitest I'm seeing lower coverage, mainly on the branches with 90%.\n\nI've noticed that even empty classes (template only) show 90% branch coverage (9/10). \n\nA minimal reproduction:\n* Create a new Angular 21 application: `ng new ng21`\n* Install v8 coverage `npm i --save-dev @vitest/coverage-v8`\n* Remove the protected title variable from app.ts `-- protected readonly title = signal('ng21');`\n* Remove the `should render title` test from app.spec.ts\n* Run `ng test --coverage`\n\nThis is the coverage I see:\n\u003cimg width=\"605\" height=\"370\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/9f6319a5-6d92-4f28-bee9-afe05c2292d5\" />\n\nSimilar from my project:\n\u003cimg width=\"728\" height=\"416\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/5ba90bf5-245e-42cb-aff4-90af3acbe3f4\" />\n\nwith the spec file as:\n```\nimport { TestBed } from '@angular/core/testing';\nimport { HeaderComponent } from './header.component';\nimport { HeaderComponent as ClsHeaderComponent, TenantDropdownComponent } from '@cls/ui-util';\nimport { MockComponent } from '@cls/ui-util/testing';\nimport { SearchComponent } from '../../schedule/components/search/search.component';\n\ndescribe('HeaderComponent', () => {\n beforeEach(async () => {\n await TestBed.configureTestingModule({\n imports: [HeaderComponent],\n providers: []\n })\n .overrideComponent(HeaderComponent, {\n remove: { imports: [SearchComponent, ClsHeaderComponent, TenantDropdownComponent] },\n add: {\n imports: [\n MockComponent({ selector: 'app-search' }) as any,\n MockComponent({ selector: 'cls-header' }) as any,\n MockComponent({ selector: 'cls-tenant-dropdown' }) as any\n ]\n }\n })\n .compileComponents();\n });\n\n function setup() {\n const fixture = TestBed.createComponent(HeaderComponent);\n\n return {\n fixture,\n app: fixture.componentInstance,\n compiled: fixture.debugElement.nativeElement\n };\n }\n\n it('should create the app', () => {\n const { app } = setup();\n expect(app).toBeTruthy();\n });\n});\n```\n\nangular.json\n```\n\"test\": {\n \"builder\": \"@angular/build:unit-test\",\n \"options\": {\n \"browsers\": [\"chromium\"],\n \"buildTarget\": \"admin-ui:build\",\n \"headless\": true,\n \"tsConfig\": \"./tsconfig.spec.json\",\n \"runnerConfig\": \"./vitest.config.ts\",\n \"coverage\": true,\n \"coverageInclude\": [\"src/app/**/*.ts\"],\n \"coverageExclude\": [\"index.ts\", \"main.ts\", \"polyfills.ts\", \"**/*.routes.ts\", \"**/*.model.ts\", \"**/*.interface.ts\"],\n \"coverageReporters\": [\"text\", \"html\", \"lcov\"],\n \"coverageThresholds\": {\n \"statements\": 90,\n \"branches\": 90,\n \"functions\": 90,\n \"lines\": 90\n }\n }\n}\n```\n\nvitest.config.ts\n```\nimport { defineConfig } from 'vitest/config';\n\nexport default defineConfig({\n test: {\n environment: 'jsdom',\n globals: true,\n setupFiles: ['src/test-setup.ts'],\n restoreMocks: true,\n coverage: {\n provider: 'v8'\n },\n browser: {\n screenshotFailures: false\n }\n }\n});\n```\n\nHave I misconfigured something? Do I have an incorrect assumption of v8 coverage or is there an issue here?\n\n### Please provide a link to a minimal reproduction of the bug\n\n_No response_\n\n### Please provide the exception or error you saw\n\n```true\n\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular CLI : 21.2.3\nAngular : 21.2.5\nNode.js : 22.13.1\nPackage Manager : npm 10.9.2\nOperating System : darwin arm64\n\n┌───────────────────────────────────┬───────────────────┬───────────────────┐\n│ Package │ Installed Version │ Requested Version │\n├───────────────────────────────────┼───────────────────┼───────────────────┤\n│ @angular/animations │ 21.2.5 │ ~21.2.0 │\n│ @angular/build │ 21.2.3 │ ^21.2.0 │\n│ @angular/cdk │ 21.2.3 │ ~21.2.0 │\n│ @angular/cli │ 21.2.3 │ ~21.2.0 │\n│ @angular/common │ 21.2.5 │ ~21.2.0 │\n│ @angular/compiler │ 21.2.5 │ ~21.2.0 │\n│ @angular/compiler-cli │ 21.2.5 │ ~21.2.0 │\n│ @angular/core │ 21.2.5 │ ~21.2.0 │\n│ @angular/forms │ 21.2.5 │ ~21.2.0 │\n│ @angular/language-service │ 21.2.5 │ ~21.2.0 │\n│ @angular/platform-browser │ 21.2.5 │ ~21.2.0 │\n│ @angular/platform-browser-dynamic │ 21.2.5 │ ~21.2.0 │\n│ @angular/router │ 21.2.5 │ ~21.2.0 │\n│ rxjs │ 7.8.2 │ ~7.8.2 │\n│ typescript │ 5.9.3 │ ~5.9.3 │\n│ vitest │ 4.1.0 │ ^4.0.18 │\n│ zone.js │ 0.15.1 │ ~0.15.0 │\n└───────────────────────────────────┴───────────────────┴──────────────────\n```\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/daniemo2","@type":"Person","name":"daniemo2"},"datePublished":"2026-03-24T20:22:52Z","url":"https://github.com/angular/angular-cli/issues/32836"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d4231625-8dd5-fcf8-9c01-ebd459788364 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8642:3CBB3E:286B062:33998F5:6B01E2BA |
| html-safe-nonce | 9a586fb6e432c04243d07eba7df0f450bd383689ab25133567518a45f5c1fe22 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjQyOjNDQkIzRToyODZCMDYyOjMzOTk4RjU6NkIwMUUyQkEiLCJ2aXNpdG9yX2lkIjoiNzY0MDI5MDI3NDk0NTY1NTQ4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7ef1c3aa0b4ebfaa499b6656272180960d3ab8ad8a53ccfca4801a99ec1c971a |
| hovercard-subject-tag | issue:4138671097 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/32836/issue_layout |
| twitter:image | https://opengraph.githubassets.com/06d13465550a4c242f856bbf3d7d2a5ed8c277f8cfc1f734c7b2317b8f95ee6e/angular/angular-cli/issues/32836 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/06d13465550a4c242f856bbf3d7d2a5ed8c277f8cfc1f734c7b2317b8f95ee6e/angular/angular-cli/issues/32836 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description I'm in the process of migrating from jasmine/karma with istanbul coverage to vitest w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | daniemo2 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width