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

Function getTestRunnerConstructor

packages/vitest/src/runtime/runners/index.ts:12–30  ·  view source on GitHub ↗
(
  config: SerializedConfig,
  moduleRunner: TestModuleRunner,
)

Source from the content-addressed store, hash-verified

10import { TestRunner } from './test'
11
12async function getTestRunnerConstructor(
13 config: SerializedConfig,
14 moduleRunner: TestModuleRunner,
15): Promise<VitestRunnerConstructor> {
16 if (!config.runner) {
17 return (
18 config.mode === 'test' ? TestRunner : NodeBenchmarkRunner
19 ) as any as VitestRunnerConstructor
20 }
21 const mod = await moduleRunner.import(config.runner)
22 if (!mod.default && typeof mod.default !== 'function') {
23 throw new Error(
24 `Runner must export a default function, but got ${typeof mod.default} imported from ${
25 config.runner
26 }`,
27 )
28 }
29 return mod.default as VitestRunnerConstructor
30}
31
32export async function resolveTestRunner(
33 config: SerializedConfig,

Callers 1

resolveTestRunnerFunction · 0.85

Calls 1

importMethod · 0.45

Tested by

no test coverage detected