@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,343 @@
|
|
|
1
|
+
import { isBuiltin, createRequire } from 'node:module';
|
|
2
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
3
|
+
import vm from 'node:vm';
|
|
4
|
+
import { ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey } from '@voidzero-dev/vite-plus-core/module-runner';
|
|
5
|
+
import { T as Traces } from './chunks/traces.CCmnQaNT.js';
|
|
6
|
+
|
|
7
|
+
const performanceNow = performance.now.bind(performance);
|
|
8
|
+
class ModuleDebug {
|
|
9
|
+
executionStack = [];
|
|
10
|
+
startCalculateModuleExecutionInfo(filename, options) {
|
|
11
|
+
const startTime = performanceNow();
|
|
12
|
+
this.executionStack.push({
|
|
13
|
+
filename,
|
|
14
|
+
startTime,
|
|
15
|
+
subImportTime: 0
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
const duration = performanceNow() - startTime;
|
|
19
|
+
const currentExecution = this.executionStack.pop();
|
|
20
|
+
if (currentExecution == null) throw new Error("Execution stack is empty, this should never happen");
|
|
21
|
+
const selfTime = duration - currentExecution.subImportTime;
|
|
22
|
+
if (this.executionStack.length > 0) this.executionStack.at(-1).subImportTime += duration;
|
|
23
|
+
return {
|
|
24
|
+
startOffset: options.startOffset,
|
|
25
|
+
external: options.external,
|
|
26
|
+
importer: options.importer,
|
|
27
|
+
duration,
|
|
28
|
+
selfTime
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isWindows = process.platform === "win32";
|
|
35
|
+
class VitestModuleEvaluator {
|
|
36
|
+
stubs = {};
|
|
37
|
+
env = createImportMetaEnvProxy();
|
|
38
|
+
vm;
|
|
39
|
+
compiledFunctionArgumentsNames;
|
|
40
|
+
compiledFunctionArgumentsValues = [];
|
|
41
|
+
primitives;
|
|
42
|
+
debug = new ModuleDebug();
|
|
43
|
+
_otel;
|
|
44
|
+
_evaluatedModules;
|
|
45
|
+
constructor(vmOptions, options = {}) {
|
|
46
|
+
this.options = options;
|
|
47
|
+
this._otel = options.traces || new Traces({ enabled: false });
|
|
48
|
+
this.vm = vmOptions;
|
|
49
|
+
this.stubs = getDefaultRequestStubs(vmOptions?.context);
|
|
50
|
+
this._evaluatedModules = options.evaluatedModules;
|
|
51
|
+
if (options.compiledFunctionArgumentsNames) this.compiledFunctionArgumentsNames = options.compiledFunctionArgumentsNames;
|
|
52
|
+
if (options.compiledFunctionArgumentsValues) this.compiledFunctionArgumentsValues = options.compiledFunctionArgumentsValues;
|
|
53
|
+
if (vmOptions) this.primitives = vm.runInContext("({ Object, Proxy, Reflect })", vmOptions.context);
|
|
54
|
+
else this.primitives = {
|
|
55
|
+
Object,
|
|
56
|
+
Proxy,
|
|
57
|
+
Reflect
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
convertIdToImportUrl(id) {
|
|
61
|
+
// TODO: vitest returns paths for external modules, but Vite returns file://
|
|
62
|
+
// REMOVE WHEN VITE 6 SUPPORT IS OVER
|
|
63
|
+
// unfortunetly, there is a bug in Vite where ID is resolved incorrectly, so we can't return files until the fix is merged
|
|
64
|
+
// https://github.com/vitejs/vite/pull/20449
|
|
65
|
+
if (!isWindows || isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id)) return id;
|
|
66
|
+
const [filepath, query] = id.split("?");
|
|
67
|
+
if (query) return `${pathToFileURL(filepath).toString()}?${query}`;
|
|
68
|
+
return pathToFileURL(filepath).toString();
|
|
69
|
+
}
|
|
70
|
+
async runExternalModule(id) {
|
|
71
|
+
if (id in this.stubs) return this.stubs[id];
|
|
72
|
+
const file = this.convertIdToImportUrl(id);
|
|
73
|
+
const importer = (this._evaluatedModules?.getModuleById(id)?.importers)?.values().next().value;
|
|
74
|
+
const filename = id.startsWith("file://") ? fileURLToPath(id) : id;
|
|
75
|
+
const finishModuleExecutionInfo = this.debug.startCalculateModuleExecutionInfo(filename, {
|
|
76
|
+
startOffset: 0,
|
|
77
|
+
external: true,
|
|
78
|
+
importer
|
|
79
|
+
});
|
|
80
|
+
const namespace = await this._otel.$("vitest.module.external", { attributes: { "code.file.path": file } }, () => this.vm ? this.vm.externalModulesExecutor.import(file) : import(file)).finally(() => {
|
|
81
|
+
this.options.moduleExecutionInfo?.set(filename, finishModuleExecutionInfo());
|
|
82
|
+
});
|
|
83
|
+
if (!this.shouldInterop(file, namespace)) return namespace;
|
|
84
|
+
const { mod, defaultExport } = interopModule(namespace);
|
|
85
|
+
const { Proxy, Reflect } = this.primitives;
|
|
86
|
+
return new Proxy(mod, {
|
|
87
|
+
get(mod, prop) {
|
|
88
|
+
if (prop === "default") return defaultExport;
|
|
89
|
+
return mod[prop] ?? defaultExport?.[prop];
|
|
90
|
+
},
|
|
91
|
+
has(mod, prop) {
|
|
92
|
+
if (prop === "default") return defaultExport !== void 0;
|
|
93
|
+
return prop in mod || defaultExport && prop in defaultExport;
|
|
94
|
+
},
|
|
95
|
+
getOwnPropertyDescriptor(mod, prop) {
|
|
96
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
97
|
+
if (descriptor) return descriptor;
|
|
98
|
+
if (prop === "default" && defaultExport !== void 0) return {
|
|
99
|
+
value: defaultExport,
|
|
100
|
+
enumerable: true,
|
|
101
|
+
configurable: true
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async runInlinedModule(context, code, module) {
|
|
107
|
+
return this._otel.$("vitest.module.inline", (span) => this._runInlinedModule(context, code, module, span));
|
|
108
|
+
}
|
|
109
|
+
async _runInlinedModule(context, code, module, span) {
|
|
110
|
+
context.__vite_ssr_import_meta__.env = this.env;
|
|
111
|
+
const { Reflect, Proxy, Object } = this.primitives;
|
|
112
|
+
const exportsObject = context[ssrModuleExportsKey];
|
|
113
|
+
const SYMBOL_NOT_DEFINED = Symbol("not defined");
|
|
114
|
+
let moduleExports = SYMBOL_NOT_DEFINED;
|
|
115
|
+
// this proxy is triggered only on exports.{name} and module.exports access
|
|
116
|
+
// inside the module itself. imported module is always "exports"
|
|
117
|
+
const cjsExports = new Proxy(exportsObject, {
|
|
118
|
+
get: (target, p, receiver) => {
|
|
119
|
+
if (Reflect.has(target, p)) return Reflect.get(target, p, receiver);
|
|
120
|
+
return Reflect.get(Object.prototype, p, receiver);
|
|
121
|
+
},
|
|
122
|
+
getPrototypeOf: () => Object.prototype,
|
|
123
|
+
set: (_, p, value) => {
|
|
124
|
+
span.addEvent(`cjs export proxy is triggered for ${String(p)}`);
|
|
125
|
+
// treat "module.exports =" the same as "exports.default =" to not have nested "default.default",
|
|
126
|
+
// so "exports.default" becomes the actual module
|
|
127
|
+
if (p === "default" && this.shouldInterop(module.file, { default: value }) && cjsExports !== value) {
|
|
128
|
+
span.addEvent("`exports.default` is assigned, copying values");
|
|
129
|
+
exportAll(cjsExports, value);
|
|
130
|
+
exportsObject.default = value;
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
if (!Reflect.has(exportsObject, "default")) exportsObject.default = {};
|
|
134
|
+
// returns undefined, when accessing named exports, if default is not an object
|
|
135
|
+
// but is still present inside hasOwnKeys, this is Node behaviour for CJS
|
|
136
|
+
if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports)) {
|
|
137
|
+
span.addEvent(`\`exports.${String(p)}\` is assigned, but module.exports is a primitive. assigning "undefined" values instead to comply with ESM`);
|
|
138
|
+
defineExport(exportsObject, p, () => void 0);
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if (!isPrimitive(exportsObject.default)) exportsObject.default[p] = value;
|
|
142
|
+
if (p !== "default") defineExport(exportsObject, p, () => value);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const moduleProxy = {
|
|
147
|
+
set exports(value) {
|
|
148
|
+
span.addEvent("`module.exports` is assigned directly, copying all properties to `exports`");
|
|
149
|
+
exportAll(cjsExports, value);
|
|
150
|
+
exportsObject.default = value;
|
|
151
|
+
moduleExports = value;
|
|
152
|
+
},
|
|
153
|
+
get exports() {
|
|
154
|
+
return cjsExports;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const meta = context[ssrImportMetaKey];
|
|
158
|
+
if (this.options.getCurrentTestFilepath?.() === module.file) {
|
|
159
|
+
const globalNamespace = this.vm?.context || globalThis;
|
|
160
|
+
Object.defineProperty(meta, "vitest", { get: () => globalNamespace.__vitest_index__ });
|
|
161
|
+
}
|
|
162
|
+
const filename = meta.filename;
|
|
163
|
+
const dirname = meta.dirname;
|
|
164
|
+
span.setAttributes({ "code.file.path": filename });
|
|
165
|
+
const require = this.createRequire(meta.url);
|
|
166
|
+
const argumentsList = [
|
|
167
|
+
ssrModuleExportsKey,
|
|
168
|
+
ssrImportMetaKey,
|
|
169
|
+
ssrImportKey,
|
|
170
|
+
ssrDynamicImportKey,
|
|
171
|
+
ssrExportAllKey,
|
|
172
|
+
"__vite_ssr_exportName__",
|
|
173
|
+
"__filename",
|
|
174
|
+
"__dirname",
|
|
175
|
+
"module",
|
|
176
|
+
"exports",
|
|
177
|
+
"require"
|
|
178
|
+
];
|
|
179
|
+
if (this.compiledFunctionArgumentsNames) argumentsList.push(...this.compiledFunctionArgumentsNames);
|
|
180
|
+
span.setAttribute("vitest.module.arguments", argumentsList);
|
|
181
|
+
// add 'use strict' since ESM enables it by default
|
|
182
|
+
const codeDefinition = `'use strict';async (${argumentsList.join(",")})=>{{`;
|
|
183
|
+
const wrappedCode = `${codeDefinition}${code}\n}}`;
|
|
184
|
+
const options = {
|
|
185
|
+
filename: module.id,
|
|
186
|
+
lineOffset: 0,
|
|
187
|
+
columnOffset: -codeDefinition.length
|
|
188
|
+
};
|
|
189
|
+
// this will always be 1 element because it's cached after load
|
|
190
|
+
const importer = module.importers.values().next().value;
|
|
191
|
+
const finishModuleExecutionInfo = this.debug.startCalculateModuleExecutionInfo(options.filename, {
|
|
192
|
+
startOffset: codeDefinition.length,
|
|
193
|
+
importer
|
|
194
|
+
});
|
|
195
|
+
try {
|
|
196
|
+
await (this.vm ? vm.runInContext(wrappedCode, this.vm.context, options) : vm.runInThisContext(wrappedCode, options))(
|
|
197
|
+
context[ssrModuleExportsKey],
|
|
198
|
+
context[ssrImportMetaKey],
|
|
199
|
+
context[ssrImportKey],
|
|
200
|
+
context[ssrDynamicImportKey],
|
|
201
|
+
context[ssrExportAllKey],
|
|
202
|
+
// vite 7 support, remove when vite 7+ is supported
|
|
203
|
+
context.__vite_ssr_exportName__ || ((name, getter) => Object.defineProperty(exportsObject, name, {
|
|
204
|
+
enumerable: true,
|
|
205
|
+
configurable: true,
|
|
206
|
+
get: getter
|
|
207
|
+
})),
|
|
208
|
+
filename,
|
|
209
|
+
dirname,
|
|
210
|
+
moduleProxy,
|
|
211
|
+
cjsExports,
|
|
212
|
+
require,
|
|
213
|
+
...this.compiledFunctionArgumentsValues
|
|
214
|
+
);
|
|
215
|
+
} finally {
|
|
216
|
+
// moduleExecutionInfo needs to use Node filename instead of the normalized one
|
|
217
|
+
// because we rely on this behaviour in coverage-v8, for example
|
|
218
|
+
this.options.moduleExecutionInfo?.set(options.filename, finishModuleExecutionInfo());
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
createRequire(filename) {
|
|
222
|
+
return this.vm ? this.vm.externalModulesExecutor.createRequire(filename) : createRequire(filename);
|
|
223
|
+
}
|
|
224
|
+
shouldInterop(path, mod) {
|
|
225
|
+
if (this.options.interopDefault === false) return false;
|
|
226
|
+
// never interop ESM modules
|
|
227
|
+
// TODO: should also skip for `.js` with `type="module"`
|
|
228
|
+
return !path.endsWith(".mjs") && "default" in mod;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function createImportMetaEnvProxy() {
|
|
232
|
+
// packages/vitest/src/node/plugins/index.ts:146
|
|
233
|
+
const booleanKeys = [
|
|
234
|
+
"DEV",
|
|
235
|
+
"PROD",
|
|
236
|
+
"SSR"
|
|
237
|
+
];
|
|
238
|
+
return new Proxy(process.env, {
|
|
239
|
+
get(_, key) {
|
|
240
|
+
if (typeof key !== "string") return;
|
|
241
|
+
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
242
|
+
return process.env[key];
|
|
243
|
+
},
|
|
244
|
+
set(_, key, value) {
|
|
245
|
+
if (typeof key !== "string") return true;
|
|
246
|
+
if (booleanKeys.includes(key)) process.env[key] = value ? "1" : "";
|
|
247
|
+
else process.env[key] = value;
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function updateStyle(id, css) {
|
|
253
|
+
if (typeof document === "undefined") return;
|
|
254
|
+
const element = document.querySelector(`[data-vite-dev-id="${id}"]`);
|
|
255
|
+
if (element) {
|
|
256
|
+
element.textContent = css;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const head = document.querySelector("head");
|
|
260
|
+
const style = document.createElement("style");
|
|
261
|
+
style.setAttribute("type", "text/css");
|
|
262
|
+
style.setAttribute("data-vite-dev-id", id);
|
|
263
|
+
style.textContent = css;
|
|
264
|
+
head?.appendChild(style);
|
|
265
|
+
}
|
|
266
|
+
function removeStyle(id) {
|
|
267
|
+
if (typeof document === "undefined") return;
|
|
268
|
+
const sheet = document.querySelector(`[data-vite-dev-id="${id}"]`);
|
|
269
|
+
if (sheet) document.head.removeChild(sheet);
|
|
270
|
+
}
|
|
271
|
+
const defaultClientStub = {
|
|
272
|
+
injectQuery: (id) => id,
|
|
273
|
+
createHotContext: () => {
|
|
274
|
+
return {
|
|
275
|
+
accept: () => {},
|
|
276
|
+
prune: () => {},
|
|
277
|
+
dispose: () => {},
|
|
278
|
+
decline: () => {},
|
|
279
|
+
invalidate: () => {},
|
|
280
|
+
on: () => {},
|
|
281
|
+
send: () => {}
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
updateStyle: () => {},
|
|
285
|
+
removeStyle: () => {}
|
|
286
|
+
};
|
|
287
|
+
function getDefaultRequestStubs(context) {
|
|
288
|
+
if (!context) {
|
|
289
|
+
const clientStub = {
|
|
290
|
+
...defaultClientStub,
|
|
291
|
+
updateStyle,
|
|
292
|
+
removeStyle
|
|
293
|
+
};
|
|
294
|
+
return { "/@vite/client": clientStub };
|
|
295
|
+
}
|
|
296
|
+
const clientStub = vm.runInContext(`(defaultClient) => ({ ...defaultClient, updateStyle: ${updateStyle.toString()}, removeStyle: ${removeStyle.toString()} })`, context)(defaultClientStub);
|
|
297
|
+
return { "/@vite/client": clientStub };
|
|
298
|
+
}
|
|
299
|
+
function exportAll(exports$1, sourceModule) {
|
|
300
|
+
// #1120 when a module exports itself it causes
|
|
301
|
+
// call stack error
|
|
302
|
+
if (exports$1 === sourceModule) return;
|
|
303
|
+
if (isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise) return;
|
|
304
|
+
for (const key in sourceModule) if (key !== "default" && !(key in exports$1)) try {
|
|
305
|
+
defineExport(exports$1, key, () => sourceModule[key]);
|
|
306
|
+
} catch {}
|
|
307
|
+
}
|
|
308
|
+
// keep consistency with Vite on how exports are defined
|
|
309
|
+
function defineExport(exports$1, key, value) {
|
|
310
|
+
Object.defineProperty(exports$1, key, {
|
|
311
|
+
enumerable: true,
|
|
312
|
+
configurable: true,
|
|
313
|
+
get: value
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
function isPrimitive(v) {
|
|
317
|
+
return !(typeof v === "object" || typeof v === "function") || v == null;
|
|
318
|
+
}
|
|
319
|
+
function interopModule(mod) {
|
|
320
|
+
if (isPrimitive(mod)) return {
|
|
321
|
+
mod: { default: mod },
|
|
322
|
+
defaultExport: mod
|
|
323
|
+
};
|
|
324
|
+
let defaultExport = "default" in mod ? mod.default : mod;
|
|
325
|
+
if (!isPrimitive(defaultExport) && "__esModule" in defaultExport) {
|
|
326
|
+
mod = defaultExport;
|
|
327
|
+
if ("default" in defaultExport) defaultExport = defaultExport.default;
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
mod,
|
|
331
|
+
defaultExport
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
335
|
+
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
336
|
+
function wrapId(id) {
|
|
337
|
+
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
338
|
+
}
|
|
339
|
+
function unwrapId(id) {
|
|
340
|
+
return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, "\0") : id;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export { VitestModuleEvaluator, createImportMetaEnvProxy, getDefaultRequestStubs, isPrimitive, unwrapId, wrapId };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Browser-safe stub for module-runner
|
|
2
|
+
// The real module-runner contains Node.js-only code that crashes browsers
|
|
3
|
+
// This stub provides placeholder exports for browser compatibility
|
|
4
|
+
|
|
5
|
+
// Stub class - browser doesn't actually use these
|
|
6
|
+
export class EvaluatedModules {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.idToModuleMap = new Map();
|
|
9
|
+
this.fileToModulesMap = new Map();
|
|
10
|
+
this.urlToIdModuleMap = new Map();
|
|
11
|
+
}
|
|
12
|
+
getModuleById() { return undefined; }
|
|
13
|
+
getModulesByFile() { return []; }
|
|
14
|
+
getModuleByUrl() { return undefined; }
|
|
15
|
+
ensureModule() { return {}; }
|
|
16
|
+
invalidateModule() {}
|
|
17
|
+
clear() {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ModuleRunner {
|
|
21
|
+
constructor() {}
|
|
22
|
+
async import() { throw new Error('ModuleRunner is not available in browser'); }
|
|
23
|
+
evaluatedModules = new EvaluatedModules();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class ESModulesEvaluator {
|
|
27
|
+
constructor() {}
|
|
28
|
+
async runExternalModule() { return {}; }
|
|
29
|
+
async runViteModule() { return {}; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Stub functions
|
|
33
|
+
export function createDefaultImportMeta() { return {}; }
|
|
34
|
+
export function createNodeImportMeta() { return {}; }
|
|
35
|
+
export function createWebSocketModuleRunnerTransport() { return {}; }
|
|
36
|
+
export function normalizeModuleId(id) { return id; }
|
|
37
|
+
|
|
38
|
+
// SSR-related constants (browser doesn't use these)
|
|
39
|
+
export const ssrDynamicImportKey = '__vite_ssr_dynamic_import__';
|
|
40
|
+
export const ssrExportAllKey = '__vite_ssr_exportAll__';
|
|
41
|
+
export const ssrExportNameKey = '__vite_ssr_export__';
|
|
42
|
+
export const ssrImportKey = '__vite_ssr_import__';
|
|
43
|
+
export const ssrImportMetaKey = '__vite_ssr_import_meta__';
|
|
44
|
+
export const ssrModuleExportsKey = '__vite_ssr_exports__';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { VitestModuleEvaluator } from './module-evaluator.js';
|
|
2
|
+
export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.DEj0jb3e.js';
|
|
3
|
+
export { g as getWorkerState } from './chunks/utils.DvEY5TfP.js';
|
|
4
|
+
import 'node:module';
|
|
5
|
+
import 'node:url';
|
|
6
|
+
import 'node:vm';
|
|
7
|
+
import '@voidzero-dev/vite-plus-core/module-runner';
|
|
8
|
+
import './chunks/traces.CCmnQaNT.js';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import './@vitest/utils/helpers.js';
|
|
11
|
+
import './chunks/modules.BJuCwlRJ.js';
|
|
12
|
+
import './vendor/pathe.mjs';
|
|
13
|
+
import './path.js';
|
|
14
|
+
import 'node:path';
|
|
15
|
+
import './@vitest/utils/serialize.js';
|
|
16
|
+
import './@vitest/mocker/index.js';
|
|
17
|
+
import './@vitest/utils/timers.js';
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import * as vite from '@voidzero-dev/vite-plus-core';
|
|
2
|
+
import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, ViteDevServer, LogLevel, LoggerOptions, Logger as Logger$1 } from '@voidzero-dev/vite-plus-core';
|
|
3
|
+
export { vite as Vite };
|
|
4
|
+
export { esbuildVersion, isCSSRequest, isFileLoadingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from '@voidzero-dev/vite-plus-core';
|
|
5
|
+
import { IncomingMessage } from 'node:http';
|
|
6
|
+
import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as PoolWorker, l as PoolOptions, m as WorkerRequest, n as TestSequencer, L as Logger } from './chunks/reporters.d.CWXNI2jG.js';
|
|
7
|
+
export { at as BaseCoverageOptions, Y as BenchmarkUserOptions, Z as BrowserBuiltinProvider, $ as BrowserCommand, a0 as BrowserCommandContext, a1 as BrowserConfigOptions, a2 as BrowserInstanceOption, a3 as BrowserModuleMocker, a4 as BrowserOrchestrator, a5 as BrowserProvider, a6 as BrowserProviderOption, a7 as BrowserScript, a8 as BrowserServerFactory, a9 as BrowserServerOptions, aa as BrowserServerState, ab as BrowserServerStateSession, ai as BuiltinEnvironment, ac as CDPSession, aj as CSSModuleScopeStrategy, au as CoverageIstanbulOptions, av as CoverageOptions, aw as CoverageProvider, ax as CoverageProviderModule, ay as CoverageReporter, c as CoverageV8Options, az as CustomProviderOptions, ak as DepsOptimizationOptions, al as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, t as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, o as OnTestsRerunHandler, ad as ParentProjectBrowser, am as Pool, q as PoolRunnerInitializer, r as PoolTask, ae as ProjectBrowser, an as ProjectConfig, a as ReportContext, aB as ReportedHookContext, aC as Reporter, ap as ResolveSnapshotPathHandler, aq as ResolveSnapshotPathHandlerContext, af as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ao as ResolvedProjectConfig, S as SerializedTestProject, u as TaskOptions, v as TestCase, w as TestCollection, x as TestDiagnostic, y as TestModule, z as TestModuleState, B as TestResult, D as TestResultFailed, E as TestResultPassed, F as TestResultSkipped, aD as TestRunEndReason, aA as TestRunResult, X as TestSequencerConstructor, G as TestState, K as TestSuite, N as TestSuiteState, ag as ToMatchScreenshotComparators, ah as ToMatchScreenshotOptions, ar as TypecheckConfig, U as UserWorkspaceConfig, as as VitestEnvironment, p as VitestPackageInstaller, W as WatcherTriggerPattern, s as WorkerResponse, _ as _BrowserNames, Q as experimental_getRunnerTask } from './chunks/reporters.d.CWXNI2jG.js';
|
|
8
|
+
export { C as CacheKeyIdGenerator, a as CacheKeyIdGeneratorContext, V as VitestPluginContext } from './chunks/plugin.d.CtqpEehP.js';
|
|
9
|
+
import { Awaitable } from './@vitest/utils/index.js';
|
|
10
|
+
export { SerializedError } from './@vitest/utils/index.js';
|
|
11
|
+
import { R as RuntimeRPC } from './chunks/rpc.d.RH3apGEf.js';
|
|
12
|
+
import { Writable } from 'node:stream';
|
|
13
|
+
import { C as ContextRPC } from './chunks/worker.d.Dyxm8DEL.js';
|
|
14
|
+
export { T as TestExecutionType } from './chunks/worker.d.Dyxm8DEL.js';
|
|
15
|
+
import { Debugger } from './vendor/obug.mjs';
|
|
16
|
+
import './chunks/global.d.B15mdLcR.js';
|
|
17
|
+
export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from './@vitest/runner/index.js';
|
|
18
|
+
export { b as RuntimeConfig } from './chunks/config.d.Cy95HiCx.js';
|
|
19
|
+
export { generateFileHash } from './@vitest/runner/utils.js';
|
|
20
|
+
import './chunks/browser.d.ChKACdzH.js';
|
|
21
|
+
import './chunks/traces.d.402V_yFI.js';
|
|
22
|
+
import './@vitest/mocker/index.js';
|
|
23
|
+
import './@vitest/utils/source-map.js';
|
|
24
|
+
import './@vitest/browser/index.js';
|
|
25
|
+
import './@vitest/pretty-format/index.js';
|
|
26
|
+
import './@vitest/snapshot/index.js';
|
|
27
|
+
import './@vitest/utils/diff.js';
|
|
28
|
+
import './@vitest/expect/index.js';
|
|
29
|
+
import 'vitest/optional-types.js';
|
|
30
|
+
import './chunks/benchmark.d.DAaHLpsq.js';
|
|
31
|
+
import './vendor/tinybench.mjs';
|
|
32
|
+
import './chunks/coverage.d.BZtK59WP.js';
|
|
33
|
+
import './@vitest/snapshot/manager.js';
|
|
34
|
+
import 'node:console';
|
|
35
|
+
import 'node:fs';
|
|
36
|
+
import '@voidzero-dev/vite-plus-core/module-runner';
|
|
37
|
+
import './chunks/environment.d.CrsxCzP1.js';
|
|
38
|
+
|
|
39
|
+
type RawErrsMap = Map<string, TscErrorInfo[]>;
|
|
40
|
+
interface TscErrorInfo {
|
|
41
|
+
filePath: string;
|
|
42
|
+
errCode: number;
|
|
43
|
+
errMsg: string;
|
|
44
|
+
line: number;
|
|
45
|
+
column: number;
|
|
46
|
+
}
|
|
47
|
+
interface CollectLineNumbers {
|
|
48
|
+
target: number;
|
|
49
|
+
next: number;
|
|
50
|
+
prev?: number;
|
|
51
|
+
}
|
|
52
|
+
type CollectLines = { [key in keyof CollectLineNumbers] : string };
|
|
53
|
+
interface RootAndTarget {
|
|
54
|
+
root: string;
|
|
55
|
+
targetAbsPath: string;
|
|
56
|
+
}
|
|
57
|
+
type Context = RootAndTarget & {
|
|
58
|
+
rawErrsMap: RawErrsMap;
|
|
59
|
+
openedDirs: Set<string>;
|
|
60
|
+
lastActivePath?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
declare function isValidApiRequest(config: ResolvedConfig, req: IncomingMessage): boolean;
|
|
64
|
+
|
|
65
|
+
declare function escapeTestName(label: string, dynamic: boolean): string;
|
|
66
|
+
|
|
67
|
+
interface CliOptions extends UserConfig {
|
|
68
|
+
/**
|
|
69
|
+
* Override the watch mode
|
|
70
|
+
*/
|
|
71
|
+
run?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Removes colors from the console output
|
|
74
|
+
*/
|
|
75
|
+
color?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Output collected tests as JSON or to a file
|
|
78
|
+
*/
|
|
79
|
+
json?: string | boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Output collected test files only
|
|
82
|
+
*/
|
|
83
|
+
filesOnly?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Override vite config's configLoader from cli.
|
|
86
|
+
* Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly (default: `bundle`).
|
|
87
|
+
* This is only available with **vite version 6.1.0** and above.
|
|
88
|
+
* @experimental
|
|
89
|
+
*/
|
|
90
|
+
configLoader?: InlineConfig extends {
|
|
91
|
+
configLoader?: infer T;
|
|
92
|
+
} ? T : never;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Start Vitest programmatically
|
|
96
|
+
*
|
|
97
|
+
* Returns a Vitest instance if initialized successfully.
|
|
98
|
+
*/
|
|
99
|
+
declare function startVitest(mode: VitestRunMode, cliFilters?: string[], options?: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
|
|
100
|
+
|
|
101
|
+
interface CliParseOptions {
|
|
102
|
+
allowUnknownOptions?: boolean;
|
|
103
|
+
}
|
|
104
|
+
declare function parseCLI(argv: string | string[], config?: CliParseOptions): {
|
|
105
|
+
filter: string[];
|
|
106
|
+
options: CliOptions;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
declare function resolveApiServerConfig<Options extends ApiConfig & Omit<UserConfig, "expect">>(options: Options, defaultPort: number): ApiConfig | undefined;
|
|
110
|
+
|
|
111
|
+
declare function createVitest(mode: VitestRunMode, options: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
|
|
112
|
+
|
|
113
|
+
declare class FilesNotFoundError extends Error {
|
|
114
|
+
code: string;
|
|
115
|
+
constructor(mode: "test" | "benchmark");
|
|
116
|
+
}
|
|
117
|
+
declare class GitNotFoundError extends Error {
|
|
118
|
+
code: string;
|
|
119
|
+
constructor();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare function VitestPlugin(options?: UserConfig, vitest?: Vitest): Promise<Plugin[]>;
|
|
123
|
+
|
|
124
|
+
declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$1): Promise<{
|
|
125
|
+
vitestConfig: ResolvedConfig;
|
|
126
|
+
viteConfig: ResolvedConfig$1;
|
|
127
|
+
}>;
|
|
128
|
+
|
|
129
|
+
declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | false | undefined): string[];
|
|
130
|
+
|
|
131
|
+
type RunWithFiles = (files: TestSpecification[], invalidates?: string[]) => Promise<void>;
|
|
132
|
+
interface ProcessPool {
|
|
133
|
+
name: string;
|
|
134
|
+
runTests: RunWithFiles;
|
|
135
|
+
collectTests: RunWithFiles;
|
|
136
|
+
close?: () => Awaitable<void>;
|
|
137
|
+
}
|
|
138
|
+
declare function getFilePoolName(project: TestProject): ResolvedConfig["pool"];
|
|
139
|
+
|
|
140
|
+
interface MethodsOptions {
|
|
141
|
+
cacheFs?: boolean;
|
|
142
|
+
collect?: boolean;
|
|
143
|
+
}
|
|
144
|
+
declare function createMethodsRPC(project: TestProject, methodsOptions?: MethodsOptions): RuntimeRPC;
|
|
145
|
+
|
|
146
|
+
/** @experimental */
|
|
147
|
+
declare class ForksPoolWorker implements PoolWorker {
|
|
148
|
+
readonly name: string;
|
|
149
|
+
readonly cacheFs: boolean;
|
|
150
|
+
protected readonly entrypoint: string;
|
|
151
|
+
protected execArgv: string[];
|
|
152
|
+
protected env: Partial<NodeJS.ProcessEnv>;
|
|
153
|
+
private _fork?;
|
|
154
|
+
private stdout;
|
|
155
|
+
private stderr;
|
|
156
|
+
constructor(options: PoolOptions);
|
|
157
|
+
on(event: string, callback: (arg: any) => void): void;
|
|
158
|
+
off(event: string, callback: (arg: any) => void): void;
|
|
159
|
+
send(message: WorkerRequest): void;
|
|
160
|
+
start(): Promise<void>;
|
|
161
|
+
stop(): Promise<void>;
|
|
162
|
+
deserialize(data: unknown): unknown;
|
|
163
|
+
private get fork();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** @experimental */
|
|
167
|
+
declare class ThreadsPoolWorker implements PoolWorker {
|
|
168
|
+
readonly name: string;
|
|
169
|
+
protected readonly entrypoint: string;
|
|
170
|
+
protected execArgv: string[];
|
|
171
|
+
protected env: Partial<NodeJS.ProcessEnv>;
|
|
172
|
+
private _thread?;
|
|
173
|
+
private stdout;
|
|
174
|
+
private stderr;
|
|
175
|
+
constructor(options: PoolOptions);
|
|
176
|
+
on(event: string, callback: (arg: any) => void): void;
|
|
177
|
+
off(event: string, callback: (arg: any) => void): void;
|
|
178
|
+
send(message: WorkerRequest): void;
|
|
179
|
+
start(): Promise<void>;
|
|
180
|
+
stop(): Promise<void>;
|
|
181
|
+
deserialize(data: unknown): unknown;
|
|
182
|
+
private get thread();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** @experimental */
|
|
186
|
+
declare class TypecheckPoolWorker implements PoolWorker {
|
|
187
|
+
readonly name: string;
|
|
188
|
+
private readonly project;
|
|
189
|
+
private _eventEmitter;
|
|
190
|
+
constructor(options: PoolOptions);
|
|
191
|
+
start(): Promise<void>;
|
|
192
|
+
stop(): Promise<void>;
|
|
193
|
+
canReuse(): boolean;
|
|
194
|
+
send(message: WorkerRequest): void;
|
|
195
|
+
on(event: string, callback: (arg: any) => any): void;
|
|
196
|
+
off(event: string, callback: (arg: any) => any): void;
|
|
197
|
+
deserialize(data: unknown): unknown;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** @experimental */
|
|
201
|
+
declare class VmForksPoolWorker extends ForksPoolWorker {
|
|
202
|
+
readonly name = "vmForks";
|
|
203
|
+
readonly reportMemory: true;
|
|
204
|
+
protected readonly entrypoint: string;
|
|
205
|
+
constructor(options: PoolOptions);
|
|
206
|
+
canReuse(): boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** @experimental */
|
|
210
|
+
declare class VmThreadsPoolWorker extends ThreadsPoolWorker {
|
|
211
|
+
readonly name = "vmThreads";
|
|
212
|
+
readonly reportMemory: true;
|
|
213
|
+
protected readonly entrypoint: string;
|
|
214
|
+
constructor(options: PoolOptions);
|
|
215
|
+
canReuse(): boolean;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
declare class BaseSequencer implements TestSequencer {
|
|
219
|
+
protected ctx: Vitest;
|
|
220
|
+
constructor(ctx: Vitest);
|
|
221
|
+
shard(files: TestSpecification[]): Promise<TestSpecification[]>;
|
|
222
|
+
sort(files: TestSpecification[]): Promise<TestSpecification[]>;
|
|
223
|
+
private calculateShardRange;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare function registerConsoleShortcuts(ctx: Vitest, stdin: NodeJS.ReadStream | undefined, stdout: NodeJS.WriteStream | Writable): () => void;
|
|
227
|
+
|
|
228
|
+
interface WorkerContext extends ContextRPC {}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Check if the url is allowed to be served, via the `server.fs` config.
|
|
232
|
+
* @deprecated Use the `isFileLoadingAllowed` function instead.
|
|
233
|
+
*/
|
|
234
|
+
declare function isFileServingAllowed(config: ResolvedConfig$1, url: string): boolean;
|
|
235
|
+
declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
|
|
236
|
+
|
|
237
|
+
declare function createViteLogger(console: Logger, level?: LogLevel, options?: LoggerOptions): Logger$1;
|
|
238
|
+
|
|
239
|
+
declare const rootDir: string;
|
|
240
|
+
declare const distDir: string;
|
|
241
|
+
|
|
242
|
+
declare function createDebugger(namespace: `vitest:${string}`): Debugger | undefined;
|
|
243
|
+
|
|
244
|
+
declare const version: string;
|
|
245
|
+
|
|
246
|
+
declare const createViteServer: typeof vite.createServer;
|
|
247
|
+
|
|
248
|
+
declare const rolldownVersion: string | undefined;
|
|
249
|
+
|
|
250
|
+
export { ApiConfig, BaseSequencer, ForksPoolWorker, GitNotFoundError, PoolOptions, PoolWorker, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, ThreadsPoolWorker, TypecheckPoolWorker, Vitest, VitestOptions, VitestPlugin, VitestRunMode, VmForksPoolWorker, VmThreadsPoolWorker, WorkerRequest, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, escapeTestName, getFilePoolName, isFileServingAllowed, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
|
|
251
|
+
export type { CliOptions, CliParseOptions, ProcessPool, CollectLineNumbers as TypeCheckCollectLineNumbers, CollectLines as TypeCheckCollectLines, Context as TypeCheckContext, TscErrorInfo as TypeCheckErrorInfo, RawErrsMap as TypeCheckRawErrorsMap, RootAndTarget as TypeCheckRootAndTarget, WorkerContext };
|