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

Function withSuiteFixtures

packages/runner/src/hooks.ts:405–430  ·  view source on GitHub ↗
(
  suiteHook: WithFixturesOptions['suiteHook'],
  fn: Function,
  context: InternalChainableContext | undefined,
  stackTraceError: Error,
  contextIndex = 0,
)

Source from the content-addressed store, hash-verified

403}
404
405function withSuiteFixtures(
406 suiteHook: WithFixturesOptions['suiteHook'],
407 fn: Function,
408 context: InternalChainableContext | undefined,
409 stackTraceError: Error,
410 contextIndex = 0,
411) {
412 return (...args: any[]) => {
413 const suite = args.at(-1) as Suite | File
414 const prefix = args.slice(0, -1) // this is potential "runSuite"
415
416 const wrapper = (ctx: any) => fn(...prefix, ctx, suite)
417 configureProps(wrapper, { index: contextIndex, original: fn })
418
419 const fixtures = context?.getFixtures()
420 const fileContext = fixtures?.getFileContext(suite.file)
421
422 const fixtured = withFixtures(wrapper, {
423 suiteHook,
424 fixtures,
425 context: fileContext,
426 stackTraceError,
427 })
428 return fixtured()
429 }
430}
431
432export function getAroundHookTimeout(hook: Function): number {
433 return AROUND_TIMEOUT_KEY in hook && typeof hook[AROUND_TIMEOUT_KEY] === 'number'

Callers 3

beforeAllFunction · 0.85
afterAllFunction · 0.85
aroundAllFunction · 0.85

Calls 4

configurePropsFunction · 0.90
withFixturesFunction · 0.90
atMethod · 0.80
getFileContextMethod · 0.80

Tested by

no test coverage detected