@voidzero-dev/vite-plus-test 0.0.0-0bfcc90f.20260209-0731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +691 -0
- package/browser/context.d.ts +4 -0
- package/browser/context.js +20 -0
- package/config.d.ts +3 -0
- package/coverage.d.ts +1 -0
- package/dist/@vitest/browser/client/.vite/manifest.json +24 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/@vitest/browser/client/__vitest__/bg.png +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.svg +5 -0
- package/dist/@vitest/browser/client/__vitest__/index.html +32 -0
- package/dist/@vitest/browser/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/@vitest/browser/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/@vitest/browser/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/@vitest/browser/client/error-catcher.js +82 -0
- package/dist/@vitest/browser/client/esm-client-injector.js +67 -0
- package/dist/@vitest/browser/client/favicon.svg +5 -0
- package/dist/@vitest/browser/client/orchestrator.html +35 -0
- package/dist/@vitest/browser/client/tester/tester.html +13 -0
- package/dist/@vitest/browser/client.js +456 -0
- package/dist/@vitest/browser/context.d.ts +792 -0
- package/dist/@vitest/browser/context.js +541 -0
- package/dist/@vitest/browser/expect-element.js +32 -0
- package/dist/@vitest/browser/index-D6m36C6U.js +11 -0
- package/dist/@vitest/browser/index.d.ts +73 -0
- package/dist/@vitest/browser/index.js +3513 -0
- package/dist/@vitest/browser/jest-dom.d.ts +724 -0
- package/dist/@vitest/browser/locators.d.ts +354 -0
- package/dist/@vitest/browser/locators.js +1 -0
- package/dist/@vitest/browser/matchers.d.ts +29 -0
- package/dist/@vitest/browser/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/@vitest/browser/state.js +280 -0
- package/dist/@vitest/browser/types.d.ts +69 -0
- package/dist/@vitest/browser-playwright/context.d.ts +1 -0
- package/dist/@vitest/browser-playwright/index.d.ts +106 -0
- package/dist/@vitest/browser-playwright/index.js +1111 -0
- package/dist/@vitest/browser-playwright/locators.js +114 -0
- package/dist/@vitest/browser-preview/context.d.ts +1 -0
- package/dist/@vitest/browser-preview/index.d.ts +19 -0
- package/dist/@vitest/browser-preview/index.js +148 -0
- package/dist/@vitest/browser-preview/locators.js +79 -0
- package/dist/@vitest/browser-webdriverio/context.d.ts +1 -0
- package/dist/@vitest/browser-webdriverio/index.d.ts +63 -0
- package/dist/@vitest/browser-webdriverio/index.js +600 -0
- package/dist/@vitest/browser-webdriverio/locators.js +163 -0
- package/dist/@vitest/expect/index.d.ts +807 -0
- package/dist/@vitest/expect/index.js +1875 -0
- package/dist/@vitest/mocker/auto-register.d.ts +2 -0
- package/dist/@vitest/mocker/auto-register.js +9 -0
- package/dist/@vitest/mocker/automock.d.ts +12 -0
- package/dist/@vitest/mocker/automock.js +1 -0
- package/dist/@vitest/mocker/browser.d.ts +53 -0
- package/dist/@vitest/mocker/browser.js +91 -0
- package/dist/@vitest/mocker/chunk-automock.js +354 -0
- package/dist/@vitest/mocker/chunk-interceptor-native.js +15 -0
- package/dist/@vitest/mocker/chunk-mocker.js +521 -0
- package/dist/@vitest/mocker/chunk-pathe.M-eThtNZ.js +174 -0
- package/dist/@vitest/mocker/chunk-registry.js +185 -0
- package/dist/@vitest/mocker/chunk-utils.js +16 -0
- package/dist/@vitest/mocker/index.d-C-sLYZi-.d.ts +25 -0
- package/dist/@vitest/mocker/index.d.ts +2 -0
- package/dist/@vitest/mocker/index.js +185 -0
- package/dist/@vitest/mocker/mocker.d-TnKRhz7N.d.ts +81 -0
- package/dist/@vitest/mocker/node.d.ts +800 -0
- package/dist/@vitest/mocker/node.js +966 -0
- package/dist/@vitest/mocker/redirect.d.ts +3 -0
- package/dist/@vitest/mocker/redirect.js +79 -0
- package/dist/@vitest/mocker/register.d.ts +9 -0
- package/dist/@vitest/mocker/register.js +41 -0
- package/dist/@vitest/mocker/types.d-B8CCKmHt.d.ts +107 -0
- package/dist/@vitest/pretty-format/index.d.ts +124 -0
- package/dist/@vitest/pretty-format/index.js +1022 -0
- package/dist/@vitest/runner/chunk-tasks.js +340 -0
- package/dist/@vitest/runner/index.d.ts +180 -0
- package/dist/@vitest/runner/index.js +2114 -0
- package/dist/@vitest/runner/tasks.d-C7UxawJ9.d.ts +834 -0
- package/dist/@vitest/runner/types.d.ts +183 -0
- package/dist/@vitest/runner/types.js +1 -0
- package/dist/@vitest/runner/utils.d.ts +45 -0
- package/dist/@vitest/runner/utils.js +5 -0
- package/dist/@vitest/snapshot/environment.d-DHdQ1Csl.d.ts +22 -0
- package/dist/@vitest/snapshot/environment.d.ts +16 -0
- package/dist/@vitest/snapshot/environment.js +40 -0
- package/dist/@vitest/snapshot/index.d.ts +130 -0
- package/dist/@vitest/snapshot/index.js +1437 -0
- package/dist/@vitest/snapshot/manager.d.ts +18 -0
- package/dist/@vitest/snapshot/manager.js +73 -0
- package/dist/@vitest/snapshot/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/dist/@vitest/spy/index.d.ts +384 -0
- package/dist/@vitest/spy/index.js +433 -0
- package/dist/@vitest/utils/chunk-_commonjsHelpers.js +5 -0
- package/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +156 -0
- package/dist/@vitest/utils/constants.d.ts +21 -0
- package/dist/@vitest/utils/constants.js +49 -0
- package/dist/@vitest/utils/diff.d.ts +93 -0
- package/dist/@vitest/utils/diff.js +2199 -0
- package/dist/@vitest/utils/display.d.ts +29 -0
- package/dist/@vitest/utils/display.js +742 -0
- package/dist/@vitest/utils/error.d.ts +7 -0
- package/dist/@vitest/utils/error.js +42 -0
- package/dist/@vitest/utils/helpers.d.ts +73 -0
- package/dist/@vitest/utils/helpers.js +295 -0
- package/dist/@vitest/utils/highlight.d.ts +9 -0
- package/dist/@vitest/utils/highlight.js +538 -0
- package/dist/@vitest/utils/index.d.ts +5 -0
- package/dist/@vitest/utils/index.js +1 -0
- package/dist/@vitest/utils/offset.d.ts +5 -0
- package/dist/@vitest/utils/offset.js +32 -0
- package/dist/@vitest/utils/resolver.d.ts +7 -0
- package/dist/@vitest/utils/resolver.js +71 -0
- package/dist/@vitest/utils/serialize.d.ts +3 -0
- package/dist/@vitest/utils/serialize.js +118 -0
- package/dist/@vitest/utils/source-map.d.ts +55 -0
- package/dist/@vitest/utils/source-map.js +478 -0
- package/dist/@vitest/utils/timers.d.ts +33 -0
- package/dist/@vitest/utils/timers.js +49 -0
- package/dist/@vitest/utils/types.d-BCElaP-c.d.ts +53 -0
- package/dist/@vitest/utils/types.d.ts +34 -0
- package/dist/@vitest/utils/types.js +1 -0
- package/dist/browser-compat.js +3 -0
- package/dist/browser.d.ts +46 -0
- package/dist/browser.js +20 -0
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/chunks/base.CJ0Y4ePK.js +165 -0
- package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
- package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
- package/dist/chunks/cac.DVeoLl0M.js +1409 -0
- package/dist/chunks/cli-api.B7PN_QUv.js +13672 -0
- package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/constants.D_Q9UYh-.js +36 -0
- package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
- package/dist/chunks/coverage.D_JHT54q.js +25 -0
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
- package/dist/chunks/creator.DAmOKTvJ.js +673 -0
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/defaults.BOqNVLsY.js +74 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
- package/dist/chunks/git.Bm2pzPAa.js +71 -0
- package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
- package/dist/chunks/globals.DOayXfHP.js +30 -0
- package/dist/chunks/index.6Qv1eEA6.js +109 -0
- package/dist/chunks/index.C5r1PdPD.js +231 -0
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/index.CyBMJtT7.js +727 -0
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/index.D4KonVSU.js +6343 -0
- package/dist/chunks/index.M8mOzt4Y.js +3839 -0
- package/dist/chunks/index.Z5E_ObnR.js +37 -0
- package/dist/chunks/init-forks._y3TW739.js +41 -0
- package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
- package/dist/chunks/init.B6MLFIaN.js +334 -0
- package/dist/chunks/inspector.CvyFGlXm.js +53 -0
- package/dist/chunks/modules.BJuCwlRJ.js +36 -0
- package/dist/chunks/node.Ce0vMQM7.js +14 -0
- package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
- package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
- package/dist/chunks/rpc.BoxB0q7B.js +76 -0
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
- package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
- package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
- package/dist/chunks/test.B8ej_ZHS.js +254 -0
- package/dist/chunks/traces.CCmnQaNT.js +217 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/utils.DvEY5TfP.js +52 -0
- package/dist/chunks/vi.2VT5v0um.js +3919 -0
- package/dist/chunks/vm.D3epNOPZ.js +744 -0
- package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
- package/dist/cli.js +28 -0
- package/dist/client/.vite/manifest.json +24 -0
- package/dist/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/client/__vitest__/bg.png +0 -0
- package/dist/client/__vitest__/favicon.ico +0 -0
- package/dist/client/__vitest__/favicon.svg +5 -0
- package/dist/client/__vitest__/index.html +32 -0
- package/dist/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/client/error-catcher.js +82 -0
- package/dist/client/esm-client-injector.js +67 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/orchestrator.html +35 -0
- package/dist/client/tester/tester.html +13 -0
- package/dist/client.js +456 -0
- package/dist/config.cjs +94 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +15 -0
- package/dist/context.js +541 -0
- package/dist/coverage.d.ts +118 -0
- package/dist/coverage.js +23 -0
- package/dist/dummy.js +2 -0
- package/dist/environments.d.ts +22 -0
- package/dist/environments.js +3 -0
- package/dist/expect-element.js +27 -0
- package/dist/index-D6m36C6U.js +6 -0
- package/dist/index-node.js +7 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +19 -0
- package/dist/locators.d.ts +354 -0
- package/dist/locators.js +1 -0
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/module-evaluator.d.ts +124 -0
- package/dist/module-evaluator.js +343 -0
- package/dist/module-runner-stub.js +44 -0
- package/dist/module-runner.js +17 -0
- package/dist/node.d.ts +251 -0
- package/dist/node.js +98 -0
- package/dist/path.js +7 -0
- package/dist/plugins/browser-client.mjs +2 -0
- package/dist/plugins/browser-context.mjs +2 -0
- package/dist/plugins/browser-locators.mjs +2 -0
- package/dist/plugins/browser-playwright.mjs +2 -0
- package/dist/plugins/browser-preview.mjs +2 -0
- package/dist/plugins/browser-webdriverio.mjs +2 -0
- package/dist/plugins/browser.mjs +2 -0
- package/dist/plugins/expect.mjs +2 -0
- package/dist/plugins/mocker-automock.mjs +2 -0
- package/dist/plugins/mocker-browser.mjs +2 -0
- package/dist/plugins/mocker-node.mjs +2 -0
- package/dist/plugins/mocker-redirect.mjs +2 -0
- package/dist/plugins/mocker-register.mjs +2 -0
- package/dist/plugins/mocker.mjs +2 -0
- package/dist/plugins/pretty-format.mjs +2 -0
- package/dist/plugins/runner-types.mjs +2 -0
- package/dist/plugins/runner-utils.mjs +2 -0
- package/dist/plugins/runner.mjs +2 -0
- package/dist/plugins/snapshot-environment.mjs +2 -0
- package/dist/plugins/snapshot-manager.mjs +2 -0
- package/dist/plugins/snapshot.mjs +2 -0
- package/dist/plugins/spy.mjs +2 -0
- package/dist/plugins/utils-constants.mjs +2 -0
- package/dist/plugins/utils-diff.mjs +2 -0
- package/dist/plugins/utils-display.mjs +2 -0
- package/dist/plugins/utils-error.mjs +2 -0
- package/dist/plugins/utils-helpers.mjs +2 -0
- package/dist/plugins/utils-highlight.mjs +2 -0
- package/dist/plugins/utils-offset.mjs +2 -0
- package/dist/plugins/utils-resolver.mjs +2 -0
- package/dist/plugins/utils-serialize.mjs +2 -0
- package/dist/plugins/utils-source-map.mjs +2 -0
- package/dist/plugins/utils-timers.mjs +2 -0
- package/dist/plugins/utils.mjs +2 -0
- package/dist/reporters.d.ts +27 -0
- package/dist/reporters.js +24 -0
- package/dist/runners.d.ts +50 -0
- package/dist/runners.js +19 -0
- package/dist/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +4 -0
- package/dist/spy.js +1 -0
- package/dist/state.js +280 -0
- package/dist/suite.d.ts +5 -0
- package/dist/suite.js +6 -0
- package/dist/types.d.ts +69 -0
- package/dist/vendor/chai.d.mts +1 -0
- package/dist/vendor/chai.mjs +3577 -0
- package/dist/vendor/es-module-lexer.d.mts +193 -0
- package/dist/vendor/es-module-lexer.mjs +79 -0
- package/dist/vendor/estree-walker.d.mts +583 -0
- package/dist/vendor/estree-walker.mjs +339 -0
- package/dist/vendor/expect-type.d.mts +1574 -0
- package/dist/vendor/expect-type.mjs +214 -0
- package/dist/vendor/magic-string.d.mts +261 -0
- package/dist/vendor/magic-string.mjs +1700 -0
- package/dist/vendor/obug.d.mts +56 -0
- package/dist/vendor/obug.mjs +276 -0
- package/dist/vendor/pathe.d.mts +46 -0
- package/dist/vendor/pathe.mjs +496 -0
- package/dist/vendor/picomatch.d.mts +1 -0
- package/dist/vendor/picomatch.mjs +1855 -0
- package/dist/vendor/shared-3g9mwCWP.mjs +31 -0
- package/dist/vendor/std-env.d.mts +88 -0
- package/dist/vendor/std-env.mjs +159 -0
- package/dist/vendor/tinybench.d.mts +317 -0
- package/dist/vendor/tinybench.mjs +504 -0
- package/dist/vendor/tinyexec.d.mts +72 -0
- package/dist/vendor/tinyexec.mjs +637 -0
- package/dist/vendor/tinyglobby.d.mts +157 -0
- package/dist/vendor/tinyglobby.mjs +832 -0
- package/dist/vendor/tinyrainbow.d.mts +60 -0
- package/dist/vendor/tinyrainbow.mjs +93 -0
- package/dist/vendor/vitest_browser.mjs +2 -0
- package/dist/vendor/vitest_internal_browser.mjs +2 -0
- package/dist/vendor/vitest_runner.mjs +2 -0
- package/dist/vendor/vitest_runners.mjs +2 -0
- package/dist/worker.d.ts +32 -0
- package/dist/worker.js +48 -0
- package/dist/workers/forks.js +54 -0
- package/dist/workers/runVmTests.js +95 -0
- package/dist/workers/threads.js +55 -0
- package/dist/workers/vmForks.js +36 -0
- package/dist/workers/vmThreads.js +37 -0
- package/environments.d.ts +1 -0
- package/globals.d.ts +20 -0
- package/import-meta.d.ts +5 -0
- package/importMeta.d.ts +4 -0
- package/index.cjs +5 -0
- package/index.d.cts +1 -0
- package/jsdom.d.ts +6 -0
- package/mocker.d.ts +1 -0
- package/node.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +335 -0
- package/reporters.d.ts +1 -0
- package/runners.d.ts +1 -0
- package/snapshot.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/suppress-warnings.cjs +21 -0
- package/vitest.mjs +2 -0
- package/worker.d.ts +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { M as ModuleMockerServerInterceptor } from './chunk-interceptor-native.js';
|
|
2
|
+
import { registerModuleMocker } from './register.js';
|
|
3
|
+
import './chunk-mocker.js';
|
|
4
|
+
import './index.js';
|
|
5
|
+
import './chunk-registry.js';
|
|
6
|
+
import './chunk-pathe.M-eThtNZ.js';
|
|
7
|
+
import '../spy/index.js';
|
|
8
|
+
|
|
9
|
+
registerModuleMocker(() => new ModuleMockerServerInterceptor());
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import MagicString from '../../vendor/magic-string.mjs';
|
|
2
|
+
|
|
3
|
+
interface AutomockOptions {
|
|
4
|
+
/**
|
|
5
|
+
* @default "__vitest_mocker__"
|
|
6
|
+
*/
|
|
7
|
+
globalThisAccessor?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function automockModule(code: string, mockType: "automock" | "autospy", parse: (code: string) => any, options?: AutomockOptions): MagicString;
|
|
10
|
+
|
|
11
|
+
export { automockModule };
|
|
12
|
+
export type { AutomockOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { a as automockModule } from './chunk-automock.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { M as ModuleMockerInterceptor } from './mocker.d-TnKRhz7N.js';
|
|
2
|
+
export { C as CompilerHintsOptions, b as ModuleMocker, a as ModuleMockerCompilerHints, d as ModuleMockerConfig, e as ModuleMockerRPC, R as ResolveIdResult, f as ResolveMockResult, c as createCompilerHints } from './mocker.d-TnKRhz7N.js';
|
|
3
|
+
import { StartOptions, SetupWorker } from 'msw/browser';
|
|
4
|
+
import { M as MockerRegistry, a as MockedModule } from './types.d-B8CCKmHt.js';
|
|
5
|
+
import '../spy/index.js';
|
|
6
|
+
import './index.d-C-sLYZi-.js';
|
|
7
|
+
|
|
8
|
+
interface ModuleMockerMSWInterceptorOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The identifier to access the globalThis object in the worker.
|
|
11
|
+
* This will be injected into the script as is, so make sure it's a valid JS expression.
|
|
12
|
+
* @example
|
|
13
|
+
* ```js
|
|
14
|
+
* // globalThisAccessor: '__my_variable__' produces:
|
|
15
|
+
* globalThis[__my_variable__]
|
|
16
|
+
* // globalThisAccessor: 'Symbol.for('secret:mocks')' produces:
|
|
17
|
+
* globalThis[Symbol.for('secret:mocks')]
|
|
18
|
+
* // globalThisAccessor: '"__vitest_mocker__"' (notice quotes) produces:
|
|
19
|
+
* globalThis["__vitest_mocker__"]
|
|
20
|
+
* ```
|
|
21
|
+
* @default `"__vitest_mocker__"`
|
|
22
|
+
*/
|
|
23
|
+
globalThisAccessor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Options passed down to `msw.setupWorker().start(options)`
|
|
26
|
+
*/
|
|
27
|
+
mswOptions?: StartOptions;
|
|
28
|
+
/**
|
|
29
|
+
* A pre-configured `msw.setupWorker` instance.
|
|
30
|
+
*/
|
|
31
|
+
mswWorker?: SetupWorker;
|
|
32
|
+
}
|
|
33
|
+
declare class ModuleMockerMSWInterceptor implements ModuleMockerInterceptor {
|
|
34
|
+
private readonly options;
|
|
35
|
+
protected readonly mocks: MockerRegistry;
|
|
36
|
+
private startPromise;
|
|
37
|
+
private worker;
|
|
38
|
+
constructor(options?: ModuleMockerMSWInterceptorOptions);
|
|
39
|
+
register(module: MockedModule): Promise<void>;
|
|
40
|
+
delete(url: string): Promise<void>;
|
|
41
|
+
invalidate(): Promise<void>;
|
|
42
|
+
private resolveManualMock;
|
|
43
|
+
protected init(): Promise<SetupWorker>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare class ModuleMockerServerInterceptor implements ModuleMockerInterceptor {
|
|
47
|
+
register(module: MockedModule): Promise<void>;
|
|
48
|
+
delete(id: string): Promise<void>;
|
|
49
|
+
invalidate(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { ModuleMockerInterceptor, ModuleMockerMSWInterceptor, ModuleMockerServerInterceptor };
|
|
53
|
+
export type { ModuleMockerMSWInterceptorOptions };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export { M as ModuleMocker, c as createCompilerHints } from './chunk-mocker.js';
|
|
2
|
+
import { M as MockerRegistry } from './chunk-registry.js';
|
|
3
|
+
import { c as createManualModuleSource, a as cleanUrl } from './chunk-utils.js';
|
|
4
|
+
export { M as ModuleMockerServerInterceptor } from './chunk-interceptor-native.js';
|
|
5
|
+
import './index.js';
|
|
6
|
+
import './chunk-pathe.M-eThtNZ.js';
|
|
7
|
+
|
|
8
|
+
class ModuleMockerMSWInterceptor {
|
|
9
|
+
mocks = new MockerRegistry();
|
|
10
|
+
startPromise;
|
|
11
|
+
worker;
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
if (!options.globalThisAccessor) {
|
|
15
|
+
options.globalThisAccessor = "\"__vitest_mocker__\"";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async register(module) {
|
|
19
|
+
await this.init();
|
|
20
|
+
this.mocks.add(module);
|
|
21
|
+
}
|
|
22
|
+
async delete(url) {
|
|
23
|
+
await this.init();
|
|
24
|
+
this.mocks.delete(url);
|
|
25
|
+
}
|
|
26
|
+
async invalidate() {
|
|
27
|
+
this.mocks.clear();
|
|
28
|
+
}
|
|
29
|
+
async resolveManualMock(mock) {
|
|
30
|
+
const exports$1 = Object.keys(await mock.resolve());
|
|
31
|
+
const text = createManualModuleSource(mock.url, exports$1, this.options.globalThisAccessor);
|
|
32
|
+
return new Response(text, { headers: { "Content-Type": "application/javascript" } });
|
|
33
|
+
}
|
|
34
|
+
async init() {
|
|
35
|
+
if (this.worker) {
|
|
36
|
+
return this.worker;
|
|
37
|
+
}
|
|
38
|
+
if (this.startPromise) {
|
|
39
|
+
return this.startPromise;
|
|
40
|
+
}
|
|
41
|
+
const worker = this.options.mswWorker;
|
|
42
|
+
this.startPromise = Promise.all([worker ? { setupWorker(handler) {
|
|
43
|
+
worker.use(handler);
|
|
44
|
+
return worker;
|
|
45
|
+
} } : import('msw/browser'), import('msw/core/http')]).then(([{ setupWorker }, { http }]) => {
|
|
46
|
+
const worker = setupWorker(http.get(/.+/, async ({ request }) => {
|
|
47
|
+
const path = cleanQuery(request.url.slice(location.origin.length));
|
|
48
|
+
if (!this.mocks.has(path)) {
|
|
49
|
+
return passthrough();
|
|
50
|
+
}
|
|
51
|
+
const mock = this.mocks.get(path);
|
|
52
|
+
switch (mock.type) {
|
|
53
|
+
case "manual": return this.resolveManualMock(mock);
|
|
54
|
+
case "automock":
|
|
55
|
+
case "autospy": return Response.redirect(injectQuery(path, `mock=${mock.type}`));
|
|
56
|
+
case "redirect": return Response.redirect(mock.redirect);
|
|
57
|
+
default: throw new Error(`Unknown mock type: ${mock.type}`);
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
return worker.start(this.options.mswOptions).then(() => worker);
|
|
61
|
+
}).finally(() => {
|
|
62
|
+
this.worker = worker;
|
|
63
|
+
this.startPromise = undefined;
|
|
64
|
+
});
|
|
65
|
+
return await this.startPromise;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const trailingSeparatorRE = /[?&]$/;
|
|
69
|
+
const timestampRE = /\bt=\d{13}&?\b/;
|
|
70
|
+
const versionRE = /\bv=\w{8}&?\b/;
|
|
71
|
+
function cleanQuery(url) {
|
|
72
|
+
return url.replace(timestampRE, "").replace(versionRE, "").replace(trailingSeparatorRE, "");
|
|
73
|
+
}
|
|
74
|
+
function passthrough() {
|
|
75
|
+
return new Response(null, {
|
|
76
|
+
status: 302,
|
|
77
|
+
statusText: "Passthrough",
|
|
78
|
+
headers: { "x-msw-intention": "passthrough" }
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const replacePercentageRE = /%/g;
|
|
82
|
+
function injectQuery(url, queryToInject) {
|
|
83
|
+
// encode percents for consistent behavior with pathToFileURL
|
|
84
|
+
// see #2614 for details
|
|
85
|
+
const resolvedUrl = new URL(url.replace(replacePercentageRE, "%25"), location.href);
|
|
86
|
+
const { search, hash } = resolvedUrl;
|
|
87
|
+
const pathname = cleanUrl(url);
|
|
88
|
+
return `${pathname}?${queryToInject}${search ? `&${search.slice(1)}` : ""}${hash ?? ""}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { ModuleMockerMSWInterceptor };
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import MagicString from '../../vendor/magic-string.mjs';
|
|
2
|
+
import { walk } from '../../vendor/estree-walker.mjs';
|
|
3
|
+
|
|
4
|
+
const isNodeInPatternWeakSet = new WeakSet();
|
|
5
|
+
function setIsNodeInPattern(node) {
|
|
6
|
+
return isNodeInPatternWeakSet.add(node);
|
|
7
|
+
}
|
|
8
|
+
function isNodeInPattern(node) {
|
|
9
|
+
return isNodeInPatternWeakSet.has(node);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Same logic from \@vue/compiler-core & \@vue/compiler-sfc
|
|
13
|
+
* Except this is using acorn AST
|
|
14
|
+
*/
|
|
15
|
+
function esmWalker(root, { onIdentifier, onImportMeta, onDynamicImport, onCallExpression }) {
|
|
16
|
+
const parentStack = [];
|
|
17
|
+
const varKindStack = [];
|
|
18
|
+
const scopeMap = new WeakMap();
|
|
19
|
+
const identifiers = [];
|
|
20
|
+
const setScope = (node, name) => {
|
|
21
|
+
let scopeIds = scopeMap.get(node);
|
|
22
|
+
if (scopeIds && scopeIds.has(name)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!scopeIds) {
|
|
26
|
+
scopeIds = new Set();
|
|
27
|
+
scopeMap.set(node, scopeIds);
|
|
28
|
+
}
|
|
29
|
+
scopeIds.add(name);
|
|
30
|
+
};
|
|
31
|
+
function isInScope(name, parents) {
|
|
32
|
+
return parents.some((node) => {
|
|
33
|
+
var _scopeMap$get;
|
|
34
|
+
return node && ((_scopeMap$get = scopeMap.get(node)) === null || _scopeMap$get === void 0 ? void 0 : _scopeMap$get.has(name));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function handlePattern(p, parentScope) {
|
|
38
|
+
if (p.type === "Identifier") {
|
|
39
|
+
setScope(parentScope, p.name);
|
|
40
|
+
} else if (p.type === "RestElement") {
|
|
41
|
+
handlePattern(p.argument, parentScope);
|
|
42
|
+
} else if (p.type === "ObjectPattern") {
|
|
43
|
+
p.properties.forEach((property) => {
|
|
44
|
+
if (property.type === "RestElement") {
|
|
45
|
+
setScope(parentScope, property.argument.name);
|
|
46
|
+
} else {
|
|
47
|
+
handlePattern(property.value, parentScope);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
} else if (p.type === "ArrayPattern") {
|
|
51
|
+
p.elements.forEach((element) => {
|
|
52
|
+
if (element) {
|
|
53
|
+
handlePattern(element, parentScope);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} else if (p.type === "AssignmentPattern") {
|
|
57
|
+
handlePattern(p.left, parentScope);
|
|
58
|
+
} else {
|
|
59
|
+
setScope(parentScope, p.name);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
walk(root, {
|
|
63
|
+
enter(node, parent) {
|
|
64
|
+
if (node.type === "ImportDeclaration") {
|
|
65
|
+
return this.skip();
|
|
66
|
+
}
|
|
67
|
+
// track parent stack, skip for "else-if"/"else" branches as acorn nests
|
|
68
|
+
// the ast within "if" nodes instead of flattening them
|
|
69
|
+
if (parent && !(parent.type === "IfStatement" && node === parent.alternate)) {
|
|
70
|
+
parentStack.unshift(parent);
|
|
71
|
+
}
|
|
72
|
+
// track variable declaration kind stack used by VariableDeclarator
|
|
73
|
+
if (node.type === "VariableDeclaration") {
|
|
74
|
+
varKindStack.unshift(node.kind);
|
|
75
|
+
}
|
|
76
|
+
if (node.type === "CallExpression") {
|
|
77
|
+
onCallExpression === null || onCallExpression === void 0 ? void 0 : onCallExpression(node);
|
|
78
|
+
}
|
|
79
|
+
if (node.type === "MetaProperty" && node.meta.name === "import") {
|
|
80
|
+
onImportMeta === null || onImportMeta === void 0 ? void 0 : onImportMeta(node);
|
|
81
|
+
} else if (node.type === "ImportExpression") {
|
|
82
|
+
onDynamicImport === null || onDynamicImport === void 0 ? void 0 : onDynamicImport(node);
|
|
83
|
+
}
|
|
84
|
+
if (node.type === "Identifier") {
|
|
85
|
+
if (!isInScope(node.name, parentStack) && isRefIdentifier(node, parent, parentStack)) {
|
|
86
|
+
// record the identifier, for DFS -> BFS
|
|
87
|
+
identifiers.push([node, parentStack.slice(0)]);
|
|
88
|
+
}
|
|
89
|
+
} else if (node.type === "ClassDeclaration" && node.id) {
|
|
90
|
+
// A class declaration name could shadow an import, so add its name to the parent scope
|
|
91
|
+
const parentScope = findParentScope(parentStack);
|
|
92
|
+
if (parentScope) {
|
|
93
|
+
setScope(parentScope, node.id.name);
|
|
94
|
+
}
|
|
95
|
+
} else if (node.type === "ClassExpression" && node.id) {
|
|
96
|
+
// A class expression name could shadow an import, so add its name to the scope
|
|
97
|
+
setScope(node, node.id.name);
|
|
98
|
+
} else if (isFunctionNode(node)) {
|
|
99
|
+
// If it is a function declaration, it could be shadowing an import
|
|
100
|
+
// Add its name to the scope so it won't get replaced
|
|
101
|
+
if (node.type === "FunctionDeclaration") {
|
|
102
|
+
const parentScope = findParentScope(parentStack);
|
|
103
|
+
if (parentScope) {
|
|
104
|
+
setScope(parentScope, node.id.name);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// walk function expressions and add its arguments to known identifiers
|
|
108
|
+
// so that we don't prefix them
|
|
109
|
+
node.params.forEach((p) => {
|
|
110
|
+
if (p.type === "ObjectPattern" || p.type === "ArrayPattern") {
|
|
111
|
+
handlePattern(p, node);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
walk(p.type === "AssignmentPattern" ? p.left : p, { enter(child, parent) {
|
|
115
|
+
// skip params default value of destructure
|
|
116
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "AssignmentPattern" && (parent === null || parent === void 0 ? void 0 : parent.right) === child) {
|
|
117
|
+
return this.skip();
|
|
118
|
+
}
|
|
119
|
+
if (child.type !== "Identifier") {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// do not record as scope variable if is a destructuring keyword
|
|
123
|
+
if (isStaticPropertyKey(child, parent)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// do not record if this is a default value
|
|
127
|
+
// assignment of a destructuring variable
|
|
128
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "TemplateLiteral" && (parent === null || parent === void 0 ? void 0 : parent.expressions.includes(child)) || (parent === null || parent === void 0 ? void 0 : parent.type) === "CallExpression" && (parent === null || parent === void 0 ? void 0 : parent.callee) === child) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
setScope(node, child.name);
|
|
132
|
+
} });
|
|
133
|
+
});
|
|
134
|
+
} else if (node.type === "Property" && parent.type === "ObjectPattern") {
|
|
135
|
+
// mark property in destructuring pattern
|
|
136
|
+
setIsNodeInPattern(node);
|
|
137
|
+
} else if (node.type === "VariableDeclarator") {
|
|
138
|
+
const parentFunction = findParentScope(parentStack, varKindStack[0] === "var");
|
|
139
|
+
if (parentFunction) {
|
|
140
|
+
handlePattern(node.id, parentFunction);
|
|
141
|
+
}
|
|
142
|
+
} else if (node.type === "CatchClause" && node.param) {
|
|
143
|
+
handlePattern(node.param, node);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
leave(node, parent) {
|
|
147
|
+
// untrack parent stack from above
|
|
148
|
+
if (parent && !(parent.type === "IfStatement" && node === parent.alternate)) {
|
|
149
|
+
parentStack.shift();
|
|
150
|
+
}
|
|
151
|
+
if (node.type === "VariableDeclaration") {
|
|
152
|
+
varKindStack.shift();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
// emit the identifier events in BFS so the hoisted declarations
|
|
157
|
+
// can be captured correctly
|
|
158
|
+
identifiers.forEach(([node, stack]) => {
|
|
159
|
+
if (!isInScope(node.name, stack)) {
|
|
160
|
+
const parent = stack[0];
|
|
161
|
+
const grandparent = stack[1];
|
|
162
|
+
const hasBindingShortcut = isStaticProperty(parent) && parent.shorthand && (!isNodeInPattern(parent) || isInDestructuringAssignment(parent, parentStack));
|
|
163
|
+
const classDeclaration = parent.type === "PropertyDefinition" && (grandparent === null || grandparent === void 0 ? void 0 : grandparent.type) === "ClassBody" || parent.type === "ClassDeclaration" && node === parent.superClass;
|
|
164
|
+
const classExpression = parent.type === "ClassExpression" && node === parent.id;
|
|
165
|
+
onIdentifier === null || onIdentifier === void 0 ? void 0 : onIdentifier(node, {
|
|
166
|
+
hasBindingShortcut,
|
|
167
|
+
classDeclaration,
|
|
168
|
+
classExpression
|
|
169
|
+
}, stack);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function isRefIdentifier(id, parent, parentStack) {
|
|
174
|
+
// declaration id
|
|
175
|
+
if (parent.type === "CatchClause" || (parent.type === "VariableDeclarator" || parent.type === "ClassDeclaration") && parent.id === id) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (isFunctionNode(parent)) {
|
|
179
|
+
// function declaration/expression id
|
|
180
|
+
if (parent.id === id) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
// params list
|
|
184
|
+
if (parent.params.includes(id)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// class method name
|
|
189
|
+
if (parent.type === "MethodDefinition" && !parent.computed) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
// property key
|
|
193
|
+
if (isStaticPropertyKey(id, parent)) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
// object destructuring pattern
|
|
197
|
+
if (isNodeInPattern(parent) && parent.value === id) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
// non-assignment array destructuring pattern
|
|
201
|
+
if (parent.type === "ArrayPattern" && !isInDestructuringAssignment(parent, parentStack)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
// member expression property
|
|
205
|
+
if (parent.type === "MemberExpression" && parent.property === id && !parent.computed) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
if (parent.type === "ExportSpecifier") {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
// is a special keyword but parsed as identifier
|
|
212
|
+
if (id.name === "arguments") {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
function isStaticProperty(node) {
|
|
218
|
+
return node && node.type === "Property" && !node.computed;
|
|
219
|
+
}
|
|
220
|
+
function isStaticPropertyKey(node, parent) {
|
|
221
|
+
return isStaticProperty(parent) && parent.key === node;
|
|
222
|
+
}
|
|
223
|
+
const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/;
|
|
224
|
+
function isFunctionNode(node) {
|
|
225
|
+
return functionNodeTypeRE.test(node.type);
|
|
226
|
+
}
|
|
227
|
+
const blockNodeTypeRE = /^BlockStatement$|^For(?:In|Of)?Statement$/;
|
|
228
|
+
function isBlock(node) {
|
|
229
|
+
return blockNodeTypeRE.test(node.type);
|
|
230
|
+
}
|
|
231
|
+
function findParentScope(parentStack, isVar = false) {
|
|
232
|
+
return parentStack.find(isVar ? isFunctionNode : isBlock);
|
|
233
|
+
}
|
|
234
|
+
function isInDestructuringAssignment(parent, parentStack) {
|
|
235
|
+
if (parent && (parent.type === "Property" || parent.type === "ArrayPattern")) {
|
|
236
|
+
return parentStack.some((i) => i.type === "AssignmentExpression");
|
|
237
|
+
}
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
function getArbitraryModuleIdentifier(node) {
|
|
241
|
+
return node.type === "Identifier" ? node.name : node.raw;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// TODO: better source map replacement
|
|
245
|
+
function automockModule(code, mockType, parse, options = {}) {
|
|
246
|
+
const globalThisAccessor = options.globalThisAccessor || "\"__vitest_mocker__\"";
|
|
247
|
+
const ast = parse(code);
|
|
248
|
+
const m = new MagicString(code);
|
|
249
|
+
const allSpecifiers = [];
|
|
250
|
+
let importIndex = 0;
|
|
251
|
+
for (const _node of ast.body) {
|
|
252
|
+
if (_node.type === "ExportAllDeclaration") {
|
|
253
|
+
throw new Error(`automocking files with \`export *\` is not supported in browser mode because it cannot be statically analysed`);
|
|
254
|
+
}
|
|
255
|
+
if (_node.type === "ExportNamedDeclaration") {
|
|
256
|
+
const node = _node;
|
|
257
|
+
const declaration = node.declaration;
|
|
258
|
+
function traversePattern(expression) {
|
|
259
|
+
// export const test = '1'
|
|
260
|
+
if (expression.type === "Identifier") {
|
|
261
|
+
allSpecifiers.push({ name: expression.name });
|
|
262
|
+
} else if (expression.type === "ArrayPattern") {
|
|
263
|
+
expression.elements.forEach((element) => {
|
|
264
|
+
if (!element) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
traversePattern(element);
|
|
268
|
+
});
|
|
269
|
+
} else if (expression.type === "ObjectPattern") {
|
|
270
|
+
expression.properties.forEach((property) => {
|
|
271
|
+
// export const { ...rest } = {}
|
|
272
|
+
if (property.type === "RestElement") {
|
|
273
|
+
traversePattern(property);
|
|
274
|
+
} else if (property.type === "Property") {
|
|
275
|
+
traversePattern(property.value);
|
|
276
|
+
} else ;
|
|
277
|
+
});
|
|
278
|
+
} else if (expression.type === "RestElement") {
|
|
279
|
+
traversePattern(expression.argument);
|
|
280
|
+
} else if (expression.type === "AssignmentPattern") {
|
|
281
|
+
throw new Error(`AssignmentPattern is not supported. Please open a new bug report.`);
|
|
282
|
+
} else if (expression.type === "MemberExpression") {
|
|
283
|
+
throw new Error(`MemberExpression is not supported. Please open a new bug report.`);
|
|
284
|
+
} else ;
|
|
285
|
+
}
|
|
286
|
+
if (declaration) {
|
|
287
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
288
|
+
allSpecifiers.push({ name: declaration.id.name });
|
|
289
|
+
} else if (declaration.type === "VariableDeclaration") {
|
|
290
|
+
declaration.declarations.forEach((declaration) => {
|
|
291
|
+
traversePattern(declaration.id);
|
|
292
|
+
});
|
|
293
|
+
} else if (declaration.type === "ClassDeclaration") {
|
|
294
|
+
allSpecifiers.push({ name: declaration.id.name });
|
|
295
|
+
} else ;
|
|
296
|
+
m.remove(node.start, declaration.start);
|
|
297
|
+
}
|
|
298
|
+
const specifiers = node.specifiers || [];
|
|
299
|
+
const source = node.source;
|
|
300
|
+
if (!source && specifiers.length) {
|
|
301
|
+
specifiers.forEach((specifier) => {
|
|
302
|
+
allSpecifiers.push({
|
|
303
|
+
alias: getArbitraryModuleIdentifier(specifier.exported),
|
|
304
|
+
name: getArbitraryModuleIdentifier(specifier.local)
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
m.remove(node.start, node.end);
|
|
308
|
+
} else if (source && specifiers.length) {
|
|
309
|
+
const importNames = [];
|
|
310
|
+
specifiers.forEach((specifier) => {
|
|
311
|
+
const importedName = `__vitest_imported_${importIndex++}__`;
|
|
312
|
+
importNames.push([getArbitraryModuleIdentifier(specifier.local), importedName]);
|
|
313
|
+
allSpecifiers.push({
|
|
314
|
+
name: importedName,
|
|
315
|
+
alias: getArbitraryModuleIdentifier(specifier.exported)
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
const importString = `import { ${importNames.map(([name, alias]) => `${name} as ${alias}`).join(", ")} } from '${source.value}'`;
|
|
319
|
+
m.overwrite(node.start, node.end, importString);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (_node.type === "ExportDefaultDeclaration") {
|
|
323
|
+
const node = _node;
|
|
324
|
+
const declaration = node.declaration;
|
|
325
|
+
allSpecifiers.push({
|
|
326
|
+
name: "__vitest_default",
|
|
327
|
+
alias: "default"
|
|
328
|
+
});
|
|
329
|
+
m.overwrite(node.start, declaration.start, `const __vitest_default = `);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const moduleObject = `
|
|
333
|
+
const __vitest_current_es_module__ = {
|
|
334
|
+
__esModule: true,
|
|
335
|
+
${allSpecifiers.map(({ name }) => `["${name}"]: ${name},`).join("\n ")}
|
|
336
|
+
}
|
|
337
|
+
const __vitest_mocked_module__ = globalThis[${globalThisAccessor}].mockObject(__vitest_current_es_module__, "${mockType}")
|
|
338
|
+
`;
|
|
339
|
+
const assigning = allSpecifiers.map(({ name }, index) => {
|
|
340
|
+
return `const __vitest_mocked_${index}__ = __vitest_mocked_module__["${name}"]`;
|
|
341
|
+
}).join("\n");
|
|
342
|
+
const redeclarations = allSpecifiers.map(({ name, alias }, index) => {
|
|
343
|
+
return ` __vitest_mocked_${index}__ as ${alias || name},`;
|
|
344
|
+
}).join("\n");
|
|
345
|
+
const specifiersExports = `
|
|
346
|
+
export {
|
|
347
|
+
${redeclarations}
|
|
348
|
+
}
|
|
349
|
+
`;
|
|
350
|
+
m.append(moduleObject + assigning + specifiersExports);
|
|
351
|
+
return m;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export { automockModule as a, esmWalker as e };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { r as rpc } from './chunk-mocker.js';
|
|
2
|
+
|
|
3
|
+
class ModuleMockerServerInterceptor {
|
|
4
|
+
async register(module) {
|
|
5
|
+
await rpc("vitest:interceptor:register", module.toJSON());
|
|
6
|
+
}
|
|
7
|
+
async delete(id) {
|
|
8
|
+
await rpc("vitest:interceptor:delete", id);
|
|
9
|
+
}
|
|
10
|
+
async invalidate() {
|
|
11
|
+
await rpc("vitest:interceptor:invalidate");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { ModuleMockerServerInterceptor as M };
|