MCPcopy
hub / github.com/vitest-dev/vitest / getSerializedModuleGraph

Function getSerializedModuleGraph

test/cli/test/reporters/merge-reports.test.ts:427–449  ·  view source on GitHub ↗
(ctx: Vitest)

Source from the content-addressed store, hash-verified

425})
426
427async function getSerializedModuleGraph(ctx: Vitest) {
428 const files = ctx.state.getFiles().slice().sort((a, b) => a.filepath.localeCompare(b.filepath))
429 const moduleGraphs = Object.fromEntries(
430 await Promise.all(
431 files.map(async (file) => {
432 const projectName = file.projectName || ''
433 const project = ctx.getProjectByName(projectName)
434 const graph = await getModuleGraph(
435 ctx,
436 projectName,
437 file.filepath,
438 project.config.browser.enabled,
439 )
440 return [file.filepath, graph] as const
441 }),
442 ),
443 )
444 return JSON.stringify(moduleGraphs, null, 2)
445 .replaceAll(ctx.config.root, '<root>')
446 .replace(/"[^"\n]*\/node_modules\//g, '"<node_modules>/')
447 .replace(/<node_modules>\/\.vite\/vitest\/[a-f0-9]{40}\/deps\/([^"?]+)/g, '<optimized-deps>/$1')
448 .replace(/\?v=[a-f0-9]+/g, '?v=<hash>')
449}
450
451function trimReporterOutput(report: string) {
452 const rows = report

Callers 1

Calls 5

getModuleGraphFunction · 0.90
allMethod · 0.80
getProjectByNameMethod · 0.80
sortMethod · 0.45
getFilesMethod · 0.45

Tested by

no test coverage detected