1- import { ng } from '../../utils/process';
1+ import { ng, noSilentNg } from '../../utils/process';
22import { applyVitestBuilder } from '../../utils/vitest';
33import assert from 'node:assert';
44import { installPackage } from '../../utils/packages';
55import { exec } from '../../utils/process';
66import { updateJsonFile } from '../../utils/project';
7- import { readFile } from '../../utils/fs';
7+ import { readFile, replaceInFile } from '../../utils/fs';
88
99export default async function () {
1010 await applyVitestBuilder();
@@ -59,20 +59,22 @@ export default async function () {
5959 const expectedMessage = new RegExp(`${totalTests} passed`);
6060 const coverageJsonPath = 'coverage/test-project/coverage-final.json';
6161
62+ await replaceInFile(
63+ 'node_modules/@vitest/coverage-v8/dist/provider.js',
64+ `removeStartsWith(url, FILE_PROTOCOL)`,
65+ `fileURLToPath(url)`,
66+ );
67+
6268 // Run tests in default (JSDOM) mode with coverage
63- const { stdout: jsdomStdout } = await ng ('test', '--no-watch', '--coverage');
69+ const { stdout: jsdomStdout } = await noSilentNg ('test', '--no-watch', '--coverage');
6470 assert.match(jsdomStdout, expectedMessage, `Expected ${totalTests} tests to pass in JSDOM mode.`);
6571
66- // TODO: Investigate why coverage-final.json is empty on Windows in JSDOM mode.
67- // For now, skip the coverage report check on Windows.
68- if (process.platform !== 'win32') {
69- // Assert that every generated file is in the coverage report by reading the JSON output.
70- const jsdomSummary = JSON.parse(await readFile(coverageJsonPath));
71- const jsdomSummaryKeys = Object.keys(jsdomSummary);
72- for (const file of generatedFiles) {
73- const found = jsdomSummaryKeys.some((key) => key.endsWith(file));
74- assert.ok(found, `Expected ${file} to be in the JSDOM coverage report.`);
75- }
72+ // Assert that every generated file is in the coverage report by reading the JSON output.
73+ const jsdomSummary = JSON.parse(await readFile(coverageJsonPath));
74+ const jsdomSummaryKeys = Object.keys(jsdomSummary);
75+ for (const file of generatedFiles) {
76+ const found = jsdomSummaryKeys.some((key) => key.endsWith(file));
77+ assert.ok(found, `Expected ${file} to be in the JSDOM coverage report.`);
7678 }
7779
7880 // Setup for browser mode
@@ -81,7 +83,7 @@ export default async function () {
8183 await exec('npx', 'playwright', 'install', 'chromium', '--only-shell');
8284
8385 // Run tests in browser mode with coverage
84- const { stdout: browserStdout } = await ng (
86+ const { stdout: browserStdout } = await noSilentNg (
8587 'test',
8688 '--no-watch',
8789 '--coverage',
0 commit comments