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

Method onAfterRunSuite

packages/vitest/src/runtime/runners/test.ts:91–122  ·  view source on GitHub ↗
(suite: Suite)

Source from the content-addressed store, hash-verified

89 }
90
91 async onAfterRunSuite(suite: Suite): Promise<void> {
92 if (this.config.logHeapUsage && typeof process !== 'undefined') {
93 suite.result!.heap = process.memoryUsage().heapUsed
94 }
95
96 if (suite.mode !== 'skip' && 'filepath' in suite) {
97 // mark snapshots in skipped tests as not obsolete
98 for (const test of getTests(suite)) {
99 if (test.mode === 'skip') {
100 const name = getNames(test).slice(1).join(' > ')
101 this.snapshotClient.skipTest(suite.file.filepath, name)
102 }
103 }
104
105 const result = await this.snapshotClient.finish(suite.file.filepath)
106 if (
107 this.workerState.config.snapshotOptions.updateSnapshot === 'none'
108 && result.unchecked
109 ) {
110 let message = `Obsolete snapshots found when no snapshot update is expected.\n`
111 for (const key of result.uncheckedKeys) {
112 message += `· ${key}\n`
113 }
114 suite.result!.errors ??= []
115 suite.result!.errors.push(processError(new Error(message)))
116 suite.result!.state = 'fail'
117 }
118 await rpc().snapshotSaved(result)
119 }
120
121 this.workerState.current = suite.suite || suite.file
122 }
123
124 onAfterRunTask(test: Task): void {
125 if (this.config.logHeapUsage && typeof process !== 'undefined') {

Callers 1

runSuiteFunction · 0.80

Calls 6

getTestsFunction · 0.90
getNamesFunction · 0.90
processErrorFunction · 0.90
rpcFunction · 0.90
skipTestMethod · 0.80
finishMethod · 0.45

Tested by

no test coverage detected