Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
Something went wrong. Try again.
1.3 kB · 41 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142import type { __TYPES } from 'vitest/runtime'import { __INTERNAL } from 'vitest/runtime'
const { VitestModuleEvaluator, startVitestModuleRunner, VITEST_VM_CONTEXT_SYMBOL, getWorkerState } = __INTERNAL
export function startWebWorkerModuleRunner( context: Record<string, unknown>,): __TYPES['VitestModuleRunner'] { const state = getWorkerState() const mocker = (globalThis as any).__vitest_mocker__
const compiledFunctionArgumentsNames = Object.keys(context) const compiledFunctionArgumentsValues = Object.values(context) compiledFunctionArgumentsNames.push('importScripts') compiledFunctionArgumentsValues.push(importScripts)
const vm = (globalThis as any)[VITEST_VM_CONTEXT_SYMBOL]
const evaluator = new VitestModuleEvaluator(vm, { interopDefault: state.config.deps.interopDefault, injectCjsGlobals: state.config.injectCjsGlobals, moduleExecutionInfo: state.moduleExecutionInfo, getCurrentTestFilepath: () => state.filepath, compiledFunctionArgumentsNames, compiledFunctionArgumentsValues, })
return startVitestModuleRunner({ evaluator, evaluatedModules: state.evaluatedModules, mocker, state, })}
function importScripts() { throw new Error( '[vitest] `importScripts` is not supported in Vite workers. Please, consider using `import` instead.', )}