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

Method onTestRunEnd

packages/ui/node/reporter.ts:67–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65 }
66
67 async onTestRunEnd(): Promise<void> {
68 const result: HTMLReportData = {
69 paths: this.ctx.state.getPaths(),
70 files: this.ctx.state.getFiles(),
71 config: this.ctx.serializedRootConfig,
72 unhandledErrors: this.ctx.state.getUnhandledErrors(),
73 moduleGraph: {},
74 sources: {},
75 }
76 const promises: Promise<void>[] = []
77
78 promises.push(...result.files.map(async (file) => {
79 const projectName = file.projectName || ''
80 const resolvedConfig = this.ctx.getProjectByName(projectName).config
81 const browser = resolvedConfig.browser.enabled
82 result.moduleGraph[projectName] ??= {}
83 result.moduleGraph[projectName][file.filepath] = await getModuleGraph(
84 this.ctx,
85 projectName,
86 file.filepath,
87 browser,
88 )
89 if (!result.sources[file.filepath]) {
90 try {
91 result.sources[file.filepath] = await fs.readFile(file.filepath, {
92 encoding: 'utf-8',
93 })
94 }
95 catch {
96 // just ignore
97 }
98 }
99 }))
100
101 await Promise.all(promises)
102 await this.writeReport(stringify(result))
103 }
104
105 async writeReport(report: string): Promise<void> {
106 const metaFile = resolve(this.reporterDir, 'html.meta.json.gz')

Callers

nothing calls this directly

Calls 9

writeReportMethod · 0.95
getModuleGraphFunction · 0.90
stringifyFunction · 0.85
getUnhandledErrorsMethod · 0.80
getProjectByNameMethod · 0.80
readFileMethod · 0.80
allMethod · 0.80
getPathsMethod · 0.45
getFilesMethod · 0.45

Tested by

no test coverage detected