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

Function callFixtureCleanupFrom

packages/runner/src/fixture.ts:266–279  ·  view source on GitHub ↗
(context: object, fromIndex: number)

Source from the content-addressed store, hash-verified

264 * while preserving fixtures that were created for aroundEach itself.
265 */
266export async function callFixtureCleanupFrom(context: object, fromIndex: number): Promise<void> {
267 const cleanupFnArray = cleanupFnArrayMap.get(context)
268 if (!cleanupFnArray || cleanupFnArray.length <= fromIndex) {
269 return
270 }
271 // Get items added after the checkpoint
272 const toCleanup = cleanupFnArray.slice(fromIndex)
273 // Clean up in reverse order
274 for (const cleanup of toCleanup.reverse()) {
275 await cleanup()
276 }
277 // Remove cleaned up items from the array, keeping items before checkpoint
278 cleanupFnArray.length = fromIndex
279}
280
281type SuiteHook = 'beforeAll' | 'afterAll' | 'aroundAll'
282

Callers 1

runTestFunction · 0.90

Calls 2

cleanupFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected