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

Function runBaseTests

packages/vitest/src/runtime/workers/base.ts:134–178  ·  view source on GitHub ↗
(method: 'run' | 'collect', state: WorkerGlobalState, traces: Traces)

Source from the content-addressed store, hash-verified

132
133/** @experimental */
134export async function runBaseTests(method: 'run' | 'collect', state: WorkerGlobalState, traces: Traces): Promise<void> {
135 const { ctx } = state
136 state.environment = _currentEnvironment
137 state.durations.environment = _environmentTime
138 // state has new context, but we want to reuse existing ones
139 state.evaluatedModules = evaluatedModules
140 state.moduleExecutionInfo = moduleExecutionInfo
141
142 provideWorkerState(globalThis, state)
143
144 if (ctx.invalidates) {
145 ctx.invalidates.forEach((filepath) => {
146 const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || []
147 modules.forEach((module) => {
148 state.evaluatedModules.invalidateModule(module)
149 })
150 })
151 }
152 ctx.files.forEach((i) => {
153 const filepath = i.filepath
154 const modules = state.evaluatedModules.fileToModulesMap.get(filepath) || []
155 modules.forEach((module) => {
156 state.evaluatedModules.invalidateModule(module)
157 })
158 })
159
160 const moduleRunner = await startModuleRunner({
161 state,
162 evaluatedModules: state.evaluatedModules,
163 spyModule,
164 createImportMeta: createNodeImportMeta,
165 traces,
166 })
167
168 emitModuleRunner(moduleRunner as any)
169
170 await run(
171 method,
172 ctx.files,
173 ctx.config,
174 moduleRunner,
175 _currentEnvironment,
176 traces,
177 )
178}

Callers

nothing calls this directly

Calls 5

provideWorkerStateFunction · 0.90
emitModuleRunnerFunction · 0.90
runFunction · 0.90
startModuleRunnerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected