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

Function validateSuiteHook

packages/runner/src/fixture.ts:596–610  ·  view source on GitHub ↗
(fn: Function, hook: SuiteHook, suiteError: Error | undefined)

Source from the content-addressed store, hash-verified

594}
595
596function validateSuiteHook(fn: Function, hook: SuiteHook, suiteError: Error | undefined) {
597 const usedProps = getUsedProps(fn, { sourceError: suiteError, suiteHook: hook })
598 if (usedProps.size) {
599 const error = new FixtureAccessError(
600 `The ${hook} hook uses fixtures "${[...usedProps].join('", "')}", but has no access to context. `
601 + `Did you forget to call it as "test.${hook}()" instead of "${hook}()"?\n`
602 + `If you used internal "suite" task as the first argument previously, access it in the second argument instead. `
603 + `See https://vitest.dev/guide/test-context#suite-level-hooks`,
604 )
605 if (suiteError) {
606 error.stack = suiteError.stack?.replace(suiteError.message, error.message)
607 }
608 throw error
609 }
610}
611
612const kPropsSymbol = Symbol('$vitest:fixture-props')
613const kPropNamesSymbol = Symbol('$vitest:fixture-prop-names')

Callers 1

withFixturesFunction · 0.85

Calls 1

getUsedPropsFunction · 0.85

Tested by

no test coverage detected