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,29 +59,37 @@ 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/index.js' ,
64+ `return { result };` ,
65+ `console.log(JSON.stringify(result, null, 2));return { result };` ,
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
72+ const jsdomSummary = JSON . parse ( await readFile ( coverageJsonPath ) ) ;
6673 // TODO: Investigate why coverage-final.json is empty on Windows in JSDOM mode.
6774 // For now, skip the coverage report check on Windows.
6875 if ( process . platform !== 'win32' ) {
6976 // Assert that every generated file is in the coverage report by reading the JSON output.
70- const jsdomSummary = JSON . parse ( await readFile ( coverageJsonPath ) ) ;
77+
7178 const jsdomSummaryKeys = Object . keys ( jsdomSummary ) ;
7279 for ( const file of generatedFiles ) {
7380 const found = jsdomSummaryKeys . some ( ( key ) => key . endsWith ( file ) ) ;
7481 assert . ok ( found , `Expected ${ file } to be in the JSDOM coverage report.` ) ;
7582 }
7683 }
84+ console . log ( JSON . stringify ( jsdomSummary , null , 2 ) ) ;
7785
7886 // Setup for browser mode
7987 await installPackage ( 'playwright@1' ) ;
8088 await installPackage ( '@vitest/browser-playwright@4' ) ;
8189 await exec ( 'npx' , 'playwright' , 'install' , 'chromium' , '--only-shell' ) ;
8290
8391 // Run tests in browser mode with coverage
84- const { stdout : browserStdout } = await ng (
92+ const { stdout : browserStdout } = await noSilentNg (
8593 'test' ,
8694 '--no-watch' ,
8795 '--coverage' ,
@@ -101,4 +109,6 @@ export default async function () {
101109 const found = browserSummaryKeys . some ( ( key ) => key . endsWith ( file ) ) ;
102110 assert . ok ( found , `Expected ${ file } to be in the browser coverage report.` ) ;
103111 }
112+
113+ console . log ( JSON . stringify ( browserSummaryKeys , null , 2 ) ) ;
104114}
0 commit comments