@@ -256,7 +256,7 @@ test('total and merged execution times are shown', async () => {
256256 file . tasks . push ( createTest ( 'some test' , file ) )
257257
258258 await writeBlob (
259- [ version , [ file ] , [ ] , undefined , 1500 * index , { } ] ,
259+ [ version , [ file ] , [ ] , undefined , 1500 * index , { } , { } ] ,
260260 resolve ( `./fixtures/reporters/merge-reports/.vitest-reports/blob-${ index } -2.json` ) ,
261261 )
262262 }
@@ -279,8 +279,8 @@ test('module graph available', async () => {
279279 const reportsDir = resolve ( root , '.vitest-reports' )
280280 rmSync ( reportsDir , { force : true , recursive : true } )
281281
282- async function getModuleGraphs ( ctx : Vitest ) {
283- const files = ctx . state . getFiles ( ) . slice ( ) . sort ( ( a , b ) => a . filepath . localeCompare ( b . filepath ) )
282+ async function getSerializedModuleGraph ( ctx : Vitest ) {
283+ const files = ctx . state . getFiles ( ) . slice ( ) . sort ( )
284284 const moduleGraphs = Object . fromEntries (
285285 await Promise . all (
286286 files . map ( async ( file ) => {
@@ -296,7 +296,9 @@ test('module graph available', async () => {
296296 } ) ,
297297 ) ,
298298 )
299- return JSON . stringify ( moduleGraphs , null , 2 ) . replaceAll ( ctx . config . root , '<root>' )
299+ return JSON . stringify ( moduleGraphs , null , 2 )
300+ . replaceAll ( ctx . config . root , '<root>' )
301+ . replace ( / " \/ [ ^ " \n ] * \/ n o d e _ m o d u l e s \/ / g, '"<node_modules>/' )
300302 }
301303
302304 // generate blob
@@ -305,7 +307,7 @@ test('module graph available', async () => {
305307 reporters : [ 'blob' ] ,
306308 } )
307309 expect . assert ( result . ctx )
308- const generatedModuleGraphJson = await getModuleGraphs ( result . ctx )
310+ const generatedModuleGraphJson = await getSerializedModuleGraph ( result . ctx )
309311 expect ( generatedModuleGraphJson ) . toMatchInlineSnapshot ( `
310312 "{
311313 "<root>/basic.test.ts": {
@@ -337,10 +339,13 @@ test('module graph available', async () => {
337339 "<root>/sub/subject.ts"
338340 ],
339341 "<root>/second.test.ts": [
340- "<root>/util.ts"
342+ "<root>/util.ts",
343+ "<node_modules>/obug/dist/node.js"
341344 ]
342345 },
343- "externalized": [],
346+ "externalized": [
347+ "<node_modules>/obug/dist/node.js"
348+ ],
344349 "inlined": [
345350 "<root>/second.test.ts",
346351 "<root>/util.ts",
@@ -357,7 +362,7 @@ test('module graph available', async () => {
357362 } )
358363 expect ( result2 . stderr ) . toMatchInlineSnapshot ( `""` )
359364 expect . assert ( result2 . ctx )
360- const restoredModuleGraphJson = await getModuleGraphs ( result2 . ctx )
365+ const restoredModuleGraphJson = await getSerializedModuleGraph ( result2 . ctx )
361366 expect ( restoredModuleGraphJson ) . toBe ( generatedModuleGraphJson )
362367
363368 // also check html reporter doesn't crash
0 commit comments