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

Function aroundEach

packages/runner/src/hooks.ts:377–403  ·  view source on GitHub ↗
(
  fn: AroundEachListener<ExtraContext>,
  timeout?: number,
)

Source from the content-addressed store, hash-verified

375 * ```
376 */
377export function aroundEach<ExtraContext = object>(
378 fn: AroundEachListener<ExtraContext>,
379 timeout?: number,
380): void {
381 assertTypes(fn, '"aroundEach" callback', ['function'])
382 const stackTraceError = new Error('STACK_TRACE_ERROR')
383 const resolvedTimeout = timeout ?? getDefaultHookTimeout()
384
385 const wrapper: AroundEachListener<ExtraContext> = (runTest, context, suite) => {
386 const innerFn = (ctx: any) => fn(runTest, ctx, suite)
387 configureProps(innerFn, { index: 1, original: fn })
388
389 const fixtureResolver = withFixtures(innerFn, { suite })
390 return fixtureResolver(context)
391 }
392
393 return getCurrentSuite<ExtraContext>().on(
394 'aroundEach',
395 Object.assign(
396 wrapper,
397 {
398 [AROUND_TIMEOUT_KEY]: resolvedTimeout,
399 [AROUND_STACK_TRACE_KEY]: stackTraceError,
400 },
401 ),
402 )
403}
404
405function withSuiteFixtures(
406 suiteHook: WithFixturesOptions['suiteHook'],

Callers

nothing calls this directly

Calls 4

assertTypesFunction · 0.90
getCurrentSuiteFunction · 0.90
getDefaultHookTimeoutFunction · 0.85
onMethod · 0.45

Tested by

no test coverage detected