@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,79 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import nodeModule from 'node:module';
|
|
3
|
+
import { d as dirname, j as join, b as basename, r as resolve, e as extname } from './chunk-pathe.M-eThtNZ.js';
|
|
4
|
+
|
|
5
|
+
const { existsSync, readdirSync, statSync } = fs;
|
|
6
|
+
function findMockRedirect(root, mockPath, external) {
|
|
7
|
+
const path = external || mockPath;
|
|
8
|
+
// it's a node_module alias
|
|
9
|
+
// all mocks should be inside <root>/__mocks__
|
|
10
|
+
if (external || isNodeBuiltin(mockPath) || !existsSync(mockPath)) {
|
|
11
|
+
const mockDirname = dirname(path);
|
|
12
|
+
const mockFolder = join(root, "__mocks__", mockDirname);
|
|
13
|
+
if (!existsSync(mockFolder)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const baseOriginal = basename(path);
|
|
17
|
+
function findFile(mockFolder, baseOriginal) {
|
|
18
|
+
const files = readdirSync(mockFolder);
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const baseFile = basename(file, extname(file));
|
|
21
|
+
if (baseFile === baseOriginal) {
|
|
22
|
+
const path = resolve(mockFolder, file);
|
|
23
|
+
// if the same name, return the file
|
|
24
|
+
if (statSync(path).isFile()) {
|
|
25
|
+
return path;
|
|
26
|
+
} else {
|
|
27
|
+
// find folder/index.{js,ts}
|
|
28
|
+
const indexFile = findFile(path, "index");
|
|
29
|
+
if (indexFile) {
|
|
30
|
+
return indexFile;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return findFile(mockFolder, baseOriginal);
|
|
38
|
+
}
|
|
39
|
+
const dir = dirname(path);
|
|
40
|
+
const baseId = basename(path);
|
|
41
|
+
const fullPath = resolve(dir, "__mocks__", baseId);
|
|
42
|
+
return existsSync(fullPath) ? fullPath : null;
|
|
43
|
+
}
|
|
44
|
+
const builtins = new Set([
|
|
45
|
+
...nodeModule.builtinModules,
|
|
46
|
+
"assert/strict",
|
|
47
|
+
"diagnostics_channel",
|
|
48
|
+
"dns/promises",
|
|
49
|
+
"fs/promises",
|
|
50
|
+
"path/posix",
|
|
51
|
+
"path/win32",
|
|
52
|
+
"readline/promises",
|
|
53
|
+
"stream/consumers",
|
|
54
|
+
"stream/promises",
|
|
55
|
+
"stream/web",
|
|
56
|
+
"timers/promises",
|
|
57
|
+
"util/types",
|
|
58
|
+
"wasi"
|
|
59
|
+
]);
|
|
60
|
+
// https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix
|
|
61
|
+
const prefixedBuiltins = new Set([
|
|
62
|
+
"node:sea",
|
|
63
|
+
"node:sqlite",
|
|
64
|
+
"node:test",
|
|
65
|
+
"node:test/reporters"
|
|
66
|
+
]);
|
|
67
|
+
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
68
|
+
function isNodeBuiltin(id) {
|
|
69
|
+
// Added in v18.6.0
|
|
70
|
+
if (nodeModule.isBuiltin) {
|
|
71
|
+
return nodeModule.isBuiltin(id);
|
|
72
|
+
}
|
|
73
|
+
if (prefixedBuiltins.has(id)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { findMockRedirect };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { M as ModuleMockerInterceptor, a as ModuleMockerCompilerHints, b as ModuleMocker } from './mocker.d-TnKRhz7N.js';
|
|
2
|
+
import '../spy/index.js';
|
|
3
|
+
import './types.d-B8CCKmHt.js';
|
|
4
|
+
import './index.d-C-sLYZi-.js';
|
|
5
|
+
|
|
6
|
+
declare function registerModuleMocker(interceptor: (accessor: string) => ModuleMockerInterceptor): ModuleMockerCompilerHints;
|
|
7
|
+
declare function registerNativeFactoryResolver(mocker: ModuleMocker): void;
|
|
8
|
+
|
|
9
|
+
export { registerModuleMocker, registerNativeFactoryResolver };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createMockInstance } from '../spy/index.js';
|
|
2
|
+
import { M as ModuleMocker, r as rpc, c as createCompilerHints, h as hot } from './chunk-mocker.js';
|
|
3
|
+
import './index.js';
|
|
4
|
+
import './chunk-registry.js';
|
|
5
|
+
import './chunk-pathe.M-eThtNZ.js';
|
|
6
|
+
|
|
7
|
+
function registerModuleMocker(interceptor) {
|
|
8
|
+
const mocker = new ModuleMocker(interceptor(__VITEST_GLOBAL_THIS_ACCESSOR__), {
|
|
9
|
+
resolveId(id, importer) {
|
|
10
|
+
return rpc("vitest:mocks:resolveId", {
|
|
11
|
+
id,
|
|
12
|
+
importer
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
resolveMock(id, importer, options) {
|
|
16
|
+
return rpc("vitest:mocks:resolveMock", {
|
|
17
|
+
id,
|
|
18
|
+
importer,
|
|
19
|
+
options
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
async invalidate(ids) {
|
|
23
|
+
return rpc("vitest:mocks:invalidate", { ids });
|
|
24
|
+
}
|
|
25
|
+
}, createMockInstance, { root: __VITEST_MOCKER_ROOT__ });
|
|
26
|
+
globalThis[__VITEST_GLOBAL_THIS_ACCESSOR__] = mocker;
|
|
27
|
+
registerNativeFactoryResolver(mocker);
|
|
28
|
+
return createCompilerHints({ globalThisKey: __VITEST_GLOBAL_THIS_ACCESSOR__ });
|
|
29
|
+
}
|
|
30
|
+
function registerNativeFactoryResolver(mocker) {
|
|
31
|
+
hot.on("vitest:interceptor:resolve", async (url) => {
|
|
32
|
+
const exports$1 = await mocker.resolveFactoryModule(url);
|
|
33
|
+
const keys = Object.keys(exports$1);
|
|
34
|
+
hot.send("vitest:interceptor:resolved", {
|
|
35
|
+
url,
|
|
36
|
+
keys
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { registerModuleMocker, registerNativeFactoryResolver };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
declare class MockerRegistry {
|
|
2
|
+
private readonly registryByUrl;
|
|
3
|
+
private readonly registryById;
|
|
4
|
+
clear(): void;
|
|
5
|
+
keys(): IterableIterator<string>;
|
|
6
|
+
add(mock: MockedModule): void;
|
|
7
|
+
register(json: MockedModuleSerialized): MockedModule;
|
|
8
|
+
register(type: "redirect", raw: string, id: string, url: string, redirect: string): RedirectedModule;
|
|
9
|
+
register(type: "manual", raw: string, id: string, url: string, factory: () => any): ManualMockedModule;
|
|
10
|
+
register(type: "automock", raw: string, id: string, url: string): AutomockedModule;
|
|
11
|
+
register(type: "autospy", id: string, raw: string, url: string): AutospiedModule;
|
|
12
|
+
delete(id: string): void;
|
|
13
|
+
deleteById(id: string): void;
|
|
14
|
+
get(id: string): MockedModule | undefined;
|
|
15
|
+
getById(id: string): MockedModule | undefined;
|
|
16
|
+
has(id: string): boolean;
|
|
17
|
+
}
|
|
18
|
+
type MockedModule = AutomockedModule | AutospiedModule | ManualMockedModule | RedirectedModule;
|
|
19
|
+
type MockedModuleType = "automock" | "autospy" | "manual" | "redirect";
|
|
20
|
+
type MockedModuleSerialized = AutomockedModuleSerialized | AutospiedModuleSerialized | ManualMockedModuleSerialized | RedirectedModuleSerialized;
|
|
21
|
+
declare class AutomockedModule {
|
|
22
|
+
raw: string;
|
|
23
|
+
id: string;
|
|
24
|
+
url: string;
|
|
25
|
+
readonly type = "automock";
|
|
26
|
+
constructor(raw: string, id: string, url: string);
|
|
27
|
+
static fromJSON(data: AutomockedModuleSerialized): AutospiedModule;
|
|
28
|
+
toJSON(): AutomockedModuleSerialized;
|
|
29
|
+
}
|
|
30
|
+
interface AutomockedModuleSerialized {
|
|
31
|
+
type: "automock";
|
|
32
|
+
url: string;
|
|
33
|
+
raw: string;
|
|
34
|
+
id: string;
|
|
35
|
+
}
|
|
36
|
+
declare class AutospiedModule {
|
|
37
|
+
raw: string;
|
|
38
|
+
id: string;
|
|
39
|
+
url: string;
|
|
40
|
+
readonly type = "autospy";
|
|
41
|
+
constructor(raw: string, id: string, url: string);
|
|
42
|
+
static fromJSON(data: AutospiedModuleSerialized): AutospiedModule;
|
|
43
|
+
toJSON(): AutospiedModuleSerialized;
|
|
44
|
+
}
|
|
45
|
+
interface AutospiedModuleSerialized {
|
|
46
|
+
type: "autospy";
|
|
47
|
+
url: string;
|
|
48
|
+
raw: string;
|
|
49
|
+
id: string;
|
|
50
|
+
}
|
|
51
|
+
declare class RedirectedModule {
|
|
52
|
+
raw: string;
|
|
53
|
+
id: string;
|
|
54
|
+
url: string;
|
|
55
|
+
redirect: string;
|
|
56
|
+
readonly type = "redirect";
|
|
57
|
+
constructor(raw: string, id: string, url: string, redirect: string);
|
|
58
|
+
static fromJSON(data: RedirectedModuleSerialized): RedirectedModule;
|
|
59
|
+
toJSON(): RedirectedModuleSerialized;
|
|
60
|
+
}
|
|
61
|
+
interface RedirectedModuleSerialized {
|
|
62
|
+
type: "redirect";
|
|
63
|
+
url: string;
|
|
64
|
+
id: string;
|
|
65
|
+
raw: string;
|
|
66
|
+
redirect: string;
|
|
67
|
+
}
|
|
68
|
+
declare class ManualMockedModule {
|
|
69
|
+
raw: string;
|
|
70
|
+
id: string;
|
|
71
|
+
url: string;
|
|
72
|
+
factory: () => any;
|
|
73
|
+
cache: Record<string | symbol, any> | undefined;
|
|
74
|
+
readonly type = "manual";
|
|
75
|
+
constructor(raw: string, id: string, url: string, factory: () => any);
|
|
76
|
+
resolve(): Promise<Record<string | symbol, any>>;
|
|
77
|
+
static fromJSON(data: ManualMockedModuleSerialized, factory: () => any): ManualMockedModule;
|
|
78
|
+
toJSON(): ManualMockedModuleSerialized;
|
|
79
|
+
}
|
|
80
|
+
interface ManualMockedModuleSerialized {
|
|
81
|
+
type: "manual";
|
|
82
|
+
url: string;
|
|
83
|
+
id: string;
|
|
84
|
+
raw: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
88
|
+
type ModuleMockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M = M>() => Promise<T>) => Awaitable<Partial<M>>;
|
|
89
|
+
type ModuleMockFactory = () => any;
|
|
90
|
+
interface ModuleMockOptions {
|
|
91
|
+
spy?: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface ServerMockResolution {
|
|
94
|
+
mockType: "manual" | "redirect" | "automock" | "autospy";
|
|
95
|
+
resolvedId: string;
|
|
96
|
+
resolvedUrl: string;
|
|
97
|
+
needsInterop?: boolean;
|
|
98
|
+
redirectUrl?: string | null;
|
|
99
|
+
}
|
|
100
|
+
interface ServerIdResolution {
|
|
101
|
+
id: string;
|
|
102
|
+
url: string;
|
|
103
|
+
optimized: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { AutomockedModule as A, MockerRegistry as M, RedirectedModule as R, AutospiedModule as f, ManualMockedModule as g };
|
|
107
|
+
export type { ServerMockResolution as S, MockedModule as a, ModuleMockOptions as b, ModuleMockFactoryWithHelper as c, MockedModuleType as d, ServerIdResolution as e, AutomockedModuleSerialized as h, AutospiedModuleSerialized as i, ManualMockedModuleSerialized as j, MockedModuleSerialized as k, RedirectedModuleSerialized as l, ModuleMockFactory as m };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
interface Colors {
|
|
8
|
+
comment: {
|
|
9
|
+
close: string;
|
|
10
|
+
open: string;
|
|
11
|
+
};
|
|
12
|
+
content: {
|
|
13
|
+
close: string;
|
|
14
|
+
open: string;
|
|
15
|
+
};
|
|
16
|
+
prop: {
|
|
17
|
+
close: string;
|
|
18
|
+
open: string;
|
|
19
|
+
};
|
|
20
|
+
tag: {
|
|
21
|
+
close: string;
|
|
22
|
+
open: string;
|
|
23
|
+
};
|
|
24
|
+
value: {
|
|
25
|
+
close: string;
|
|
26
|
+
open: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
type Indent = (arg0: string) => string;
|
|
30
|
+
type Refs = Array<unknown>;
|
|
31
|
+
type Print = (arg0: unknown) => string;
|
|
32
|
+
type Theme = Required<{
|
|
33
|
+
comment?: string;
|
|
34
|
+
content?: string;
|
|
35
|
+
prop?: string;
|
|
36
|
+
tag?: string;
|
|
37
|
+
value?: string;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* compare function used when sorting object keys, `null` can be used to skip over sorting.
|
|
41
|
+
*/
|
|
42
|
+
type CompareKeys = ((a: string, b: string) => number) | null | undefined;
|
|
43
|
+
type RequiredOptions = Required<PrettyFormatOptions>;
|
|
44
|
+
interface Options extends Omit<RequiredOptions, "compareKeys" | "theme"> {
|
|
45
|
+
compareKeys: CompareKeys;
|
|
46
|
+
theme: Theme;
|
|
47
|
+
}
|
|
48
|
+
interface PrettyFormatOptions {
|
|
49
|
+
callToJSON?: boolean;
|
|
50
|
+
escapeRegex?: boolean;
|
|
51
|
+
escapeString?: boolean;
|
|
52
|
+
highlight?: boolean;
|
|
53
|
+
indent?: number;
|
|
54
|
+
maxDepth?: number;
|
|
55
|
+
maxWidth?: number;
|
|
56
|
+
min?: boolean;
|
|
57
|
+
printBasicPrototype?: boolean;
|
|
58
|
+
printFunctionName?: boolean;
|
|
59
|
+
printShadowRoot?: boolean;
|
|
60
|
+
compareKeys?: CompareKeys;
|
|
61
|
+
plugins?: Plugins;
|
|
62
|
+
}
|
|
63
|
+
type OptionsReceived = PrettyFormatOptions;
|
|
64
|
+
interface Config {
|
|
65
|
+
callToJSON: boolean;
|
|
66
|
+
compareKeys: CompareKeys;
|
|
67
|
+
colors: Colors;
|
|
68
|
+
escapeRegex: boolean;
|
|
69
|
+
escapeString: boolean;
|
|
70
|
+
indent: string;
|
|
71
|
+
maxDepth: number;
|
|
72
|
+
maxWidth: number;
|
|
73
|
+
min: boolean;
|
|
74
|
+
plugins: Plugins;
|
|
75
|
+
printBasicPrototype: boolean;
|
|
76
|
+
printFunctionName: boolean;
|
|
77
|
+
printShadowRoot: boolean;
|
|
78
|
+
spacingInner: string;
|
|
79
|
+
spacingOuter: string;
|
|
80
|
+
}
|
|
81
|
+
type Printer = (val: unknown, config: Config, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
|
|
82
|
+
type Test = (arg0: any) => boolean;
|
|
83
|
+
interface NewPlugin {
|
|
84
|
+
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
85
|
+
test: Test;
|
|
86
|
+
}
|
|
87
|
+
interface PluginOptions {
|
|
88
|
+
edgeSpacing: string;
|
|
89
|
+
min: boolean;
|
|
90
|
+
spacing: string;
|
|
91
|
+
}
|
|
92
|
+
interface OldPlugin {
|
|
93
|
+
print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
|
|
94
|
+
test: Test;
|
|
95
|
+
}
|
|
96
|
+
type Plugin = NewPlugin | OldPlugin;
|
|
97
|
+
type Plugins = Array<Plugin>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
101
|
+
*
|
|
102
|
+
* This source code is licensed under the MIT license found in the
|
|
103
|
+
* LICENSE file in the root directory of this source tree.
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
declare const DEFAULT_OPTIONS: Options;
|
|
107
|
+
/**
|
|
108
|
+
* Returns a presentation string of your `val` object
|
|
109
|
+
* @param val any potential JavaScript object
|
|
110
|
+
* @param options Custom settings
|
|
111
|
+
*/
|
|
112
|
+
declare function format(val: unknown, options?: OptionsReceived): string;
|
|
113
|
+
declare const plugins: {
|
|
114
|
+
AsymmetricMatcher: NewPlugin;
|
|
115
|
+
DOMCollection: NewPlugin;
|
|
116
|
+
DOMElement: NewPlugin;
|
|
117
|
+
Immutable: NewPlugin;
|
|
118
|
+
ReactElement: NewPlugin;
|
|
119
|
+
ReactTestComponent: NewPlugin;
|
|
120
|
+
Error: NewPlugin;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { DEFAULT_OPTIONS, format, plugins };
|
|
124
|
+
export type { Colors, CompareKeys, Config, NewPlugin, OldPlugin, Options, OptionsReceived, Plugin, Plugins, PrettyFormatOptions, Printer, Refs, Theme };
|