diff --git a/packages/web-worker/src/runner.ts b/packages/web-worker/src/runner.ts index 49d00ade6e47..86abe720b923 100644 --- a/packages/web-worker/src/runner.ts +++ b/packages/web-worker/src/runner.ts @@ -3,7 +3,10 @@ import { VitestExecutor } from 'vitest/execute' export class InlineWorkerRunner extends VitestExecutor { constructor(options: ExecuteOptions, private context: any) { + // share the same mocker as main executor + const mocker = (globalThis as any).__vitest_mocker__ super(options) + this.mocker = (globalThis as any).__vitest_mocker__ = mocker } prepareContext(context: Record) {