Skip to content

Commit 212a7bb

Browse files
committed
fix(@angular/build): favor istanbul coverage provider when browser testing is enabled
When browser testing is enabled (`browsers` option configured), using V8 coverage in Chromium requires fetching and remapping source maps over CDP/HTTP for every script loaded in the browser window, causing multi-minute delays during report generation on large projects. This change updates `determineCoverageProvider` to favor `@vitest/coverage-istanbul` when browser mode is active and `@vitest/coverage-istanbul` is installed in `node_modules`. Istanbul instruments code at build time, allowing instant coverage extraction from `window.__coverage__` without CDP sourcemap resolution overhead. Explicit `coverage.provider` settings in user configuration remain fully respected. Relates to #31724 (cherry picked from commit 9a3c34b)
1 parent 0c69328 commit 212a7bb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • packages/angular/build/src/builders/unit-test/runners/vitest

packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ function determineCoverageProvider(
101101
const hasIstanbul = checkInstalled('@vitest/coverage-istanbul');
102102
const hasV8 = checkInstalled('@vitest/coverage-v8');
103103

104-
if (hasIstanbul && !hasV8) {
104+
// Favor istanbul when browser testing is enabled (to avoid slow CDP V8 HTTP sourcemap remapping)
105+
// or when only istanbul is installed.
106+
if (hasIstanbul && (browsersToCheck.length > 0 || !hasV8)) {
105107
determinedProvider = 'istanbul';
106108
} else {
107109
determinedProvider = 'v8';

0 commit comments

Comments
 (0)