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

Method _initializeGlobalSetup

packages/vitest/src/node/project.ts:233–255  ·  view source on GitHub ↗

@internal

()

Source from the content-addressed store, hash-verified

231
232 /** @internal */
233 async _initializeGlobalSetup() {
234 if (this._globalSetups) {
235 return
236 }
237
238 this._globalSetups = await loadGlobalSetupFiles(
239 this.runner,
240 this.config.globalSetup,
241 )
242
243 for (const globalSetupFile of this._globalSetups) {
244 const teardown = await globalSetupFile.setup?.(this)
245 if (teardown == null || !!globalSetupFile.teardown) {
246 continue
247 }
248 if (typeof teardown !== 'function') {
249 throw new TypeError(
250 `invalid return value in globalSetup file ${globalSetupFile.file}. Must return a function`,
251 )
252 }
253 globalSetupFile.teardown = teardown
254 }
255 }
256
257 onTestsRerun(cb: OnTestsRerunHandler): void {
258 this.vitest.onTestsRerun(cb)

Callers 1

initializeGlobalSetupMethod · 0.80

Calls 2

loadGlobalSetupFilesFunction · 0.90
setupMethod · 0.80

Tested by

no test coverage detected