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

Method override

packages/runner/src/fixture.ts:86–102  ·  view source on GitHub ↗
(runner: VitestRunner, userFixtures: UserFixtures)

Source from the content-addressed store, hash-verified

84 }
85
86 override(runner: VitestRunner, userFixtures: UserFixtures): void {
87 const { suite: currentSuite, file } = getCurrentSuite()
88 const suite = currentSuite || file
89 const isTopLevel = !currentSuite || currentSuite.file === currentSuite
90 // Create a copy of the closest parent's registrations to avoid modifying them
91 // For chained calls, this.get(suite) returns this suite's overrides; for first call, returns parent's
92 const suiteRegistrations = new Map(this.get(suite))
93 const registrations = this.parseUserFixtures(runner, userFixtures, isTopLevel, suiteRegistrations)
94 // If defined in top-level, just override all registrations
95 // We don't support overriding suite-level fixtures anyway (it will throw an error)
96 if (isTopLevel) {
97 this._registrations = registrations
98 }
99 else {
100 this._overrides.set(suite, registrations)
101 }
102 }
103
104 getFileContext(file: File): Record<string, any> {
105 if (!this._suiteContexts.has(file)) {

Callers 3

createTaskCollectorFunction · 0.80

Calls 4

getMethod · 0.95
parseUserFixturesMethod · 0.95
getCurrentSuiteFunction · 0.90
setMethod · 0.45

Tested by

no test coverage detected