vitest 5.1.0-beta.1 → 5.1.1
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/dist/browser.d.ts +8 -6
- package/dist/browser.js +10 -10
- package/dist/chunks/{base.PJyN9N0u.js → base.C2su7_N0.js} +16 -21
- package/dist/chunks/{browser.d.D7a15z82.d.ts → browser.d.B-QwH_F6.d.ts} +3 -3
- package/dist/chunks/{cac.Ccf5Je_F.js → cac.BK306qhQ.js} +29 -22
- package/dist/chunks/{cli-api.DE22LIzq.js → cli-api.D6E8EtSi.js} +990 -166
- package/dist/chunks/{config.d.BgktgHfG.d.ts → config.d.BpJq6tRA.d.ts} +43 -2
- package/dist/chunks/{console.DrMPSuFo.js → console.VJUxd1rM.js} +3 -3
- package/dist/chunks/{coverage.-bm5IxnW.js → coverage.9iqXE2gN.js} +1 -1
- package/dist/chunks/{coverage.cTDc4uSS.js → coverage.jGCktcGP.js} +1 -1
- package/dist/chunks/{creator.BQ3onxbh.js → creator.CoOCr85O.js} +17 -15
- package/dist/chunks/{display.BlTmubjj.js → display.Cj2h2zsY.js} +1 -1
- package/dist/chunks/{doctor.CPlMs7-y.js → doctor.SRjZIZuA.js} +2 -2
- package/dist/chunks/{environment.d.CbTLsZSj.d.ts → environment.d.rlpAM-ON.d.ts} +1 -1
- package/dist/chunks/{globals.TipXUFcZ.js → globals.Mxora3_v.js} +11 -10
- package/dist/chunks/{index.BFXLpwll.js → index.C7Nn66Gy.js} +79 -41
- package/dist/chunks/{index.DmDMHCg8.js → index.CAmut2NG.js} +25 -1
- package/dist/chunks/{index.BXttT2gP.js → index.DNcttN5a.js} +288 -437
- package/dist/chunks/{index.B03wg4V0.js → index.Da_szXbS.js} +5 -5
- package/dist/chunks/{index.D14IAvnE.js → index.ER9afepi.js} +269 -141
- package/dist/chunks/{index.D0heQG4v.js → index.Or9psEGe.js} +1 -1
- package/dist/chunks/{init-forks.BL1E3__4.js → init-forks.q4IoGYZe.js} +7 -1
- package/dist/chunks/{init-threads.CYXAGzKQ.js → init-threads.Bf1Frg9S.js} +1 -1
- package/dist/chunks/{init.DVorxUyL.js → init.dGO4K2C0.js} +17 -9
- package/dist/chunks/{inspector.CvyFGlXm.js → inspector.D6o1NPo1.js} +12 -1
- package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
- package/dist/chunks/{modules.BJuCwlRJ.js → moduleSourceMap.Dp1WduWi.js} +31 -1
- package/dist/chunks/{native.cdzHIdmv.js → native.D5q1ylZC.js} +3 -2
- package/dist/chunks/{nativeModuleMocker.3uBcOd84.js → nativeModuleMocker.ihb3q7Cg.js} +6 -4
- package/dist/chunks/{nativeModuleRunner.xi64Afb2.js → nativeModuleRunner.9xPIMzi7.js} +1 -1
- package/dist/chunks/{node.uQulW0ei.js → node.B9mkVmLH.js} +1 -1
- package/dist/chunks/{pathe.M-eThtNZ.Ba-7h1rE.js → pathe.M-eThtNZ.zq3TM4NT.js} +1 -1
- package/dist/chunks/{plugin.d.olEn8IL9.d.ts → plugin.d.Du7hHZwb.d.ts} +115 -41
- package/dist/chunks/{plugins.DPQHVT0p.js → plugins.BPruPOR8.js} +1 -1
- package/dist/chunks/rawSnapshot.DvoRLRNr.js +356 -0
- package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
- package/dist/chunks/{rpc.BV0XpJ5q.js → rpc.CNYWPa97.js} +3 -19
- package/dist/chunks/{rpc.d.DGFP7vWr.d.ts → rpc.d.DHfuwqP0.d.ts} +2 -2
- package/dist/chunks/{run.BfrMbGVD.js → run.zBhXlcZQ.js} +118 -51
- package/dist/chunks/{setup-common.llxJkJaD.js → setup-common.wwc_NYRJ.js} +3 -3
- package/dist/chunks/{source-map.BjWcsIL9.js → source-map.DPHGMWvM.js} +14 -14
- package/dist/chunks/{source-map.d.C5A_Tr6V.d.ts → source-map.d.xB6_75fl.d.ts} +2 -1
- package/dist/chunks/{spy.DDMXghXv.js → spy.BO0hTE3G.js} +76 -53
- package/dist/chunks/{task-utils.d.BUh7ylUT.d.ts → task-utils.d.DgSjIb7r.d.ts} +1 -1
- package/dist/chunks/{utils.DSfl_w8V.js → utils.sAsh2ClK.js} +7 -8
- package/dist/chunks/{vm.Cwj01UFE.js → vm.agn4qnmT.js} +15 -13
- package/dist/chunks/{worker.d.gsA26mmR.d.ts → worker.d.BigfbIsH.d.ts} +3 -3
- package/dist/cli.js +2 -2
- package/dist/config.d.ts +8 -8
- package/dist/index.d.ts +17 -12
- package/dist/index.js +11 -10
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +1 -1
- package/dist/node.d.ts +12 -11
- package/dist/node.js +23 -19
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.js +7 -5
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +7 -3
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +23 -21
- package/dist/workers/forks.js +24 -22
- package/dist/workers/runVmTests.js +20 -17
- package/dist/workers/threads.js +24 -22
- package/dist/workers/vmForks.js +16 -15
- package/dist/workers/vmThreads.js +16 -15
- package/dist/workers/watchdog.js +20 -0
- package/package.json +21 -21
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="chai" />
|
|
2
|
+
import { FetchResult } from 'vite/module-runner';
|
|
2
3
|
import { Disposable } from 'vitest/optional-runtime-types.js';
|
|
3
4
|
import { Fn, FnOptions, BenchOptions as BenchOptions$1, TaskResultCompleted, TaskResultRuntimeInfo, TaskResultTimestampProviderInfo, Statistics } from 'tinybench';
|
|
4
5
|
|
|
@@ -284,6 +285,32 @@ interface RawSnapshotInfo {
|
|
|
284
285
|
readonly?: boolean;
|
|
285
286
|
content?: string;
|
|
286
287
|
}
|
|
288
|
+
interface RawSnapshot extends RawSnapshotInfo {
|
|
289
|
+
snapshot: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
interface InlineSnapshot {
|
|
293
|
+
snapshot: string;
|
|
294
|
+
testId: string;
|
|
295
|
+
file: string;
|
|
296
|
+
line: number;
|
|
297
|
+
column: number;
|
|
298
|
+
assertionName?: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
interface InlineSnapshotUpdate extends InlineSnapshot {
|
|
302
|
+
type: "inline";
|
|
303
|
+
}
|
|
304
|
+
interface FileSnapshotUpdate {
|
|
305
|
+
type: "file";
|
|
306
|
+
file: string;
|
|
307
|
+
key: string;
|
|
308
|
+
snapshot: string;
|
|
309
|
+
}
|
|
310
|
+
interface RawSnapshotUpdate extends RawSnapshot {
|
|
311
|
+
type: "raw";
|
|
312
|
+
}
|
|
313
|
+
type SnapshotUpdate = InlineSnapshotUpdate | FileSnapshotUpdate | RawSnapshotUpdate;
|
|
287
314
|
|
|
288
315
|
interface SnapshotEnvironment {
|
|
289
316
|
getVersion: () => string;
|
|
@@ -321,6 +348,7 @@ interface SnapshotReturnOptions {
|
|
|
321
348
|
expected?: string;
|
|
322
349
|
key: string;
|
|
323
350
|
pass: boolean;
|
|
351
|
+
update?: SnapshotUpdate;
|
|
324
352
|
}
|
|
325
353
|
interface SaveStatus {
|
|
326
354
|
deleted: boolean;
|
|
@@ -373,6 +401,7 @@ declare class SnapshotState {
|
|
|
373
401
|
private _resolveKey;
|
|
374
402
|
private _resolveInlineStack;
|
|
375
403
|
private _reconcile;
|
|
404
|
+
private _createUpdate;
|
|
376
405
|
save(): Promise<SaveStatus>;
|
|
377
406
|
getUncheckedCount(): number;
|
|
378
407
|
getUncheckedKeys(): Array<string>;
|
|
@@ -656,6 +685,10 @@ interface ResolveFunctionResult {
|
|
|
656
685
|
url: string;
|
|
657
686
|
}
|
|
658
687
|
type ModuleType = "cjs" | "esm";
|
|
688
|
+
type VitestFetchResult = FetchResult & {
|
|
689
|
+
moduleType?: ModuleType;
|
|
690
|
+
sourceMap?: string;
|
|
691
|
+
};
|
|
659
692
|
interface FetchCachedFileSystemResult {
|
|
660
693
|
cached: true;
|
|
661
694
|
tmp: string;
|
|
@@ -3426,6 +3459,10 @@ interface FailureScreenshotArtifactAttachment extends TestAttachment {
|
|
|
3426
3459
|
interface FailureScreenshotArtifact extends TestArtifactBase {
|
|
3427
3460
|
type: "internal:failureScreenshot";
|
|
3428
3461
|
attachments: [FailureScreenshotArtifactAttachment] | [];
|
|
3462
|
+
/** The zero-based retry index of the attempt that took the screenshot. */
|
|
3463
|
+
retryIndex?: number;
|
|
3464
|
+
/** The zero-based repeat index of the attempt that took the screenshot. */
|
|
3465
|
+
repeatIndex?: number;
|
|
3429
3466
|
}
|
|
3430
3467
|
/**
|
|
3431
3468
|
* @experimental
|
|
@@ -3745,6 +3782,7 @@ interface SerializedConfig {
|
|
|
3745
3782
|
port?: number;
|
|
3746
3783
|
host?: string;
|
|
3747
3784
|
waitForDebugger?: boolean;
|
|
3785
|
+
openInMainProcess?: boolean;
|
|
3748
3786
|
};
|
|
3749
3787
|
watch: boolean;
|
|
3750
3788
|
env: Record<string, any>;
|
|
@@ -3768,6 +3806,7 @@ interface SerializedConfig {
|
|
|
3768
3806
|
trace: BrowserTraceViewMode;
|
|
3769
3807
|
traceView: {
|
|
3770
3808
|
enabled: boolean;
|
|
3809
|
+
mode: BrowserTraceViewRecordingMode;
|
|
3771
3810
|
recordCanvas: boolean;
|
|
3772
3811
|
inlineImages: boolean;
|
|
3773
3812
|
ariaSnapshot: boolean;
|
|
@@ -3802,6 +3841,7 @@ interface SerializedConfig {
|
|
|
3802
3841
|
viteModuleRunner: boolean;
|
|
3803
3842
|
nodeLoader: boolean;
|
|
3804
3843
|
recordDependencies: boolean;
|
|
3844
|
+
traceTimeline: boolean;
|
|
3805
3845
|
openTelemetry: {
|
|
3806
3846
|
enabled: boolean;
|
|
3807
3847
|
sdkPath?: string;
|
|
@@ -3832,7 +3872,8 @@ type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookT
|
|
|
3832
3872
|
};
|
|
3833
3873
|
};
|
|
3834
3874
|
type RuntimeOptions = Partial<RuntimeConfig>;
|
|
3875
|
+
type BrowserTraceViewRecordingMode = "off" | "on" | "failure-only";
|
|
3835
3876
|
type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
|
|
3836
3877
|
|
|
3837
|
-
export { fn as B, _vitest_spy as _, createChainable as a2, afterAll as b9, afterEach as ba, aroundAll as bb, aroundEach as bc, beforeAll as bd, beforeEach as be, onTestFailed as bf, onTestFinished as bg, disableDefaultColors as bj, SnapshotState as
|
|
3838
|
-
export type { TestTryOptions as $, Awaitable as A, MaybeMockedDeep as C, DiffOptions as D, ExpectStatic as E, FileSpecification as F, MaybeMocked as G, MaybePartiallyMocked as H, MaybePartiallyMockedDeep as I, MockInstance as J, TestAPI as K, LabelColor as L, ModuleGraphData as M, SuiteCollector as N, SuiteAPI as O, ParsedStack as P, Suite as Q, RuntimeOptions as R, SerializedCoverageConfig as S, TestError as T, UserConsoleLog as U, VitestRunner as V, SuiteHooks as W, VitestRunnerImportSource as X, Task as Y, CancelReason as Z, File as a, TestArtifactLocation as a$, TestContext as a0, ImportDuration as a1, AfterSuiteRunMeta as a3, Assertion as a4, AsymmetricMatchersContaining as a5, BaselineData as a6, Bench as a7, BenchFn as a8, BenchFnOptions as a9, Mocked as aA, MockedClass as aB, MockedFunction as aC, MockedObject as aD, OnTestFailedHandler as aE, OnTestFinishedHandler as aF, RunMode as aG, TaskBase as aH, TaskResult as aI, TaskResultAttempt as aJ, RuntimeConfig as aK, SerializedError as aL, SnapshotData as aM, SnapshotMatchOptions as aN, SnapshotResult as aO, SnapshotSerializer as aP, SnapshotStateOptions as aQ, SnapshotSummary as aR, SnapshotUpdateState as aS, SuiteFactory as aT, SuiteOptions as aU, TaskCustomOptions as aV, TaskMeta as aW, TaskState as aX, TestAnnotationArtifact as aY, TestAnnotationLocation as aZ, TestArtifactBase as a_, BenchFromSource as aa, BenchOptions as ab, BenchRegistration as ac, BenchRegistrationInput as ad, BenchResult as ae, BenchRunOptions as af, BenchStorage as ag, BenchmarkGroup as ah, BenchmarkProvider as ai, BrowserTraceArtifact as aj, DeeplyAllowMatchers as ak, DomainMatchResult as al, FailureScreenshotArtifact as am, JestAssertion as an, RawMatcherFn as ao, Matchers as ap, MatchersObject as aq, MockContext as ar, MockResult as as, MockResultIncomplete as at, MockResultReturn as au, MockResultThrow as av, MockSettledResult as aw, MockSettledResultFulfilled as ax, MockSettledResultIncomplete as ay, MockSettledResultRejected as az, SerializedConfig as b, TestArtifactRegistry as b0, TestAttachment as b1, TestBenchmark as b2, TestBenchmarkTask as b3, TestFunction as b4, TestOptions as b5, TestTags as b6, UncheckedSnapshot as b7, VisualRegressionArtifact as b8, SequenceHooks as bh, SequenceSetupFiles as bi, SerializableRetry as bk, BrowserTraceViewMode as bl,
|
|
3878
|
+
export { fn as B, _vitest_spy as _, createChainable as a2, afterAll as b9, afterEach as ba, aroundAll as bb, aroundEach as bc, beforeAll as bd, beforeEach as be, onTestFailed as bf, onTestFinished as bg, disableDefaultColors as bj, SnapshotState as bq, format as f, inspect as i, stringify as s, spyOn as z };
|
|
3879
|
+
export type { TestTryOptions as $, Awaitable as A, MaybeMockedDeep as C, DiffOptions as D, ExpectStatic as E, FileSpecification as F, MaybeMocked as G, MaybePartiallyMocked as H, MaybePartiallyMockedDeep as I, MockInstance as J, TestAPI as K, LabelColor as L, ModuleGraphData as M, SuiteCollector as N, SuiteAPI as O, ParsedStack as P, Suite as Q, RuntimeOptions as R, SerializedCoverageConfig as S, TestError as T, UserConsoleLog as U, VitestRunner as V, SuiteHooks as W, VitestRunnerImportSource as X, Task as Y, CancelReason as Z, File as a, TestArtifactLocation as a$, TestContext as a0, ImportDuration as a1, AfterSuiteRunMeta as a3, Assertion as a4, AsymmetricMatchersContaining as a5, BaselineData as a6, Bench as a7, BenchFn as a8, BenchFnOptions as a9, Mocked as aA, MockedClass as aB, MockedFunction as aC, MockedObject as aD, OnTestFailedHandler as aE, OnTestFinishedHandler as aF, RunMode as aG, TaskBase as aH, TaskResult as aI, TaskResultAttempt as aJ, RuntimeConfig as aK, SerializedError as aL, SnapshotData as aM, SnapshotMatchOptions as aN, SnapshotResult as aO, SnapshotSerializer as aP, SnapshotStateOptions as aQ, SnapshotSummary as aR, SnapshotUpdateState as aS, SuiteFactory as aT, SuiteOptions as aU, TaskCustomOptions as aV, TaskMeta as aW, TaskState as aX, TestAnnotationArtifact as aY, TestAnnotationLocation as aZ, TestArtifactBase as a_, BenchFromSource as aa, BenchOptions as ab, BenchRegistration as ac, BenchRegistrationInput as ad, BenchResult as ae, BenchRunOptions as af, BenchStorage as ag, BenchmarkGroup as ah, BenchmarkProvider as ai, BrowserTraceArtifact as aj, DeeplyAllowMatchers as ak, DomainMatchResult as al, FailureScreenshotArtifact as am, JestAssertion as an, RawMatcherFn as ao, Matchers as ap, MatchersObject as aq, MockContext as ar, MockResult as as, MockResultIncomplete as at, MockResultReturn as au, MockResultThrow as av, MockSettledResult as aw, MockSettledResultFulfilled as ax, MockSettledResultIncomplete as ay, MockSettledResultRejected as az, SerializedConfig as b, TestArtifactRegistry as b0, TestAttachment as b1, TestBenchmark as b2, TestBenchmarkTask as b3, TestFunction as b4, TestOptions as b5, TestTags as b6, UncheckedSnapshot as b7, VisualRegressionArtifact as b8, SequenceHooks as bh, SequenceSetupFiles as bi, SerializableRetry as bk, BrowserTraceViewMode as bl, BrowserTraceViewRecordingMode as bm, Arrayable as bn, AsyncLeak as bo, PrettyFormatOptions as bp, PromisifyAssertion as br, Tester as bs, Plugin as bt, SnapshotEnvironment as bu, SnapshotEnvironmentOptions as bv, VitestFetchResult as bw, FetchCachedFileSystemResult as bx, ResolveFunctionResult as by, SerializedDiffOptions as c, StringifyOptions as d, FakeTimersConfig as e, TestTagDefinition as g, TestAnnotation as h, TestArtifact as j, TaskResultPack as k, TaskEventPack as l, SerializedRootConfig as m, Test as n, TaskPopulated as o, ProvidedContext as p, MatcherState as q, SyncExpectationResult as r, AsyncExpectationResult as t, DomainSnapshotAdapter as u, ExpectationResult as v, Procedure as w, Mock as x, TemporalTimelike as y };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Console } from 'node:console';
|
|
2
2
|
import { relative } from 'node:path';
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
|
-
import { a as getSafeTimers } from './source-map.
|
|
4
|
+
import { a as getSafeTimers } from './source-map.DPHGMWvM.js';
|
|
5
5
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
6
6
|
import { g as getWorkerState, E as EnvironmentTeardownError } from './utils.DYj33du9.js';
|
|
7
|
-
import './index.
|
|
8
|
-
import './pathe.M-eThtNZ.
|
|
7
|
+
import './index.Or9psEGe.js';
|
|
8
|
+
import './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
9
9
|
|
|
10
10
|
const RealDate = globalThis.Date;
|
|
11
11
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveCoverageProviderModule } from './coverage.
|
|
1
|
+
import { r as resolveCoverageProviderModule } from './coverage.jGCktcGP.js';
|
|
2
2
|
|
|
3
3
|
async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
4
4
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolve } from './pathe.M-eThtNZ.
|
|
1
|
+
import { r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
2
2
|
|
|
3
3
|
function getCoverageFilesDirectory(reportsDirectory, shard) {
|
|
4
4
|
return resolve(reportsDirectory, `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`);
|
|
@@ -2,13 +2,13 @@ import { existsSync, writeFileSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve, dirname, relative } from 'node:path';
|
|
4
4
|
import { detectPackageManager, installPackage } from './index.BoyTG_B7.js';
|
|
5
|
-
import { p as prompt, n as findConfigFile } from './index.
|
|
5
|
+
import { p as prompt, n as findConfigFile } from './index.ER9afepi.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
7
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
8
8
|
import 'node:process';
|
|
9
9
|
import 'node:url';
|
|
10
|
-
import './pathe.M-eThtNZ.
|
|
11
|
-
import './nativeModuleRunner.
|
|
10
|
+
import './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
11
|
+
import './nativeModuleRunner.9xPIMzi7.js';
|
|
12
12
|
import 'node:module';
|
|
13
13
|
import 'node:assert';
|
|
14
14
|
import 'node:v8';
|
|
@@ -21,34 +21,36 @@ import './defaults.B1FCaFfh.js';
|
|
|
21
21
|
import 'node:os';
|
|
22
22
|
import './env.BKKtU2WC.js';
|
|
23
23
|
import 'std-env';
|
|
24
|
+
import './inspector.D6o1NPo1.js';
|
|
24
25
|
import 'node:crypto';
|
|
25
26
|
import '../path.js';
|
|
26
|
-
import './
|
|
27
|
+
import './moduleSourceMap.Dp1WduWi.js';
|
|
28
|
+
import 'node:buffer';
|
|
27
29
|
import 'magic-string';
|
|
28
30
|
import '@vitest/mocker/node';
|
|
29
31
|
import 'node:console';
|
|
30
32
|
import 'node:stream';
|
|
31
|
-
import './display.
|
|
32
|
-
import './index.
|
|
33
|
+
import './display.Cj2h2zsY.js';
|
|
34
|
+
import './index.Or9psEGe.js';
|
|
35
|
+
import 'node:child_process';
|
|
33
36
|
import 'node:perf_hooks';
|
|
34
|
-
import './source-map.
|
|
35
|
-
import './run.
|
|
37
|
+
import './source-map.DPHGMWvM.js';
|
|
38
|
+
import './run.zBhXlcZQ.js';
|
|
36
39
|
import '../task-utils.js';
|
|
37
40
|
import 'obug';
|
|
38
|
-
import './resolver.
|
|
41
|
+
import './resolver.BzpmeQeT.js';
|
|
39
42
|
import 'es-module-lexer';
|
|
40
43
|
import './offset.Dy-5Fdfn.js';
|
|
41
|
-
import './utils.
|
|
44
|
+
import './utils.sAsh2ClK.js';
|
|
42
45
|
import '#module-evaluator';
|
|
46
|
+
import './index.CAmut2NG.js';
|
|
43
47
|
import 'picomatch';
|
|
44
|
-
import './module-dependencies.
|
|
45
|
-
import './coverage.
|
|
48
|
+
import './module-dependencies._2Eei3FO.js';
|
|
49
|
+
import './coverage.jGCktcGP.js';
|
|
46
50
|
import 'node:tty';
|
|
47
51
|
import 'node:events';
|
|
48
|
-
import './index.DmDMHCg8.js';
|
|
49
|
-
import 'node:child_process';
|
|
50
52
|
import 'node:worker_threads';
|
|
51
|
-
import './cac.
|
|
53
|
+
import './cac.BK306qhQ.js';
|
|
52
54
|
import 'events';
|
|
53
55
|
import 'readline';
|
|
54
56
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as format$1, p as plugins, c as createDOMElementFilter } from './index.
|
|
1
|
+
import { f as format$1, p as plugins, c as createDOMElementFilter } from './index.Or9psEGe.js';
|
|
2
2
|
|
|
3
3
|
const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
|
|
4
4
|
const PLUGINS = [
|
|
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { performance } from 'node:perf_hooks';
|
|
6
6
|
import { pathToFileURL } from 'node:url';
|
|
7
|
-
import { t as toArray, r as resolve } from './pathe.M-eThtNZ.
|
|
7
|
+
import { t as toArray, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
8
8
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
9
9
|
import { distDir } from '../path.js';
|
|
10
10
|
|
|
@@ -100,7 +100,7 @@ function log(...args) {
|
|
|
100
100
|
console.log(...args);
|
|
101
101
|
}
|
|
102
102
|
async function doctor(cliFilters, options) {
|
|
103
|
-
const { prepareVitest } = await import('./cli-api.
|
|
103
|
+
const { prepareVitest } = await import('./cli-api.D6E8EtSi.js').then(function (n) { return n.j; });
|
|
104
104
|
log();
|
|
105
105
|
log($.inverse($.bold($.blue(" DOCTOR "))), "resolving the current configuration...");
|
|
106
106
|
const ctx = await prepareVitest({
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.DLYM6cZY.js';
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './run.
|
|
4
|
-
import './index.
|
|
2
|
+
import { i as index } from './index.DNcttN5a.js';
|
|
3
|
+
import './run.zBhXlcZQ.js';
|
|
4
|
+
import './index.Or9psEGe.js';
|
|
5
5
|
import './tinyrainbow.Do8I1XRG.js';
|
|
6
|
-
import './display.
|
|
7
|
-
import './pathe.M-eThtNZ.
|
|
8
|
-
import './source-map.
|
|
6
|
+
import './display.Cj2h2zsY.js';
|
|
7
|
+
import './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
8
|
+
import './source-map.DPHGMWvM.js';
|
|
9
9
|
import '../task-utils.js';
|
|
10
10
|
import './utils.DYj33du9.js';
|
|
11
|
-
import './spy.
|
|
11
|
+
import './spy.BO0hTE3G.js';
|
|
12
12
|
import 'chai';
|
|
13
|
-
import './plugins.
|
|
13
|
+
import './plugins.BPruPOR8.js';
|
|
14
|
+
import './rawSnapshot.DvoRLRNr.js';
|
|
14
15
|
import './offset.Dy-5Fdfn.js';
|
|
15
|
-
import './
|
|
16
|
+
import './index.CAmut2NG.js';
|
|
16
17
|
import 'vite/module-runner';
|
|
17
|
-
import './index.DmDMHCg8.js';
|
|
18
18
|
import 'tinybench';
|
|
19
|
+
import './rpc.CNYWPa97.js';
|
|
19
20
|
import 'expect-type';
|
|
20
21
|
|
|
21
22
|
function registerApiGlobally() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs__default from 'node:fs';
|
|
2
|
-
import { n as normalize,
|
|
3
|
-
import { i as isBuiltin, a as isBrowserExternal, t as toBuiltin } from './
|
|
2
|
+
import { n as normalize, m as splitFileAndPostfix$1, j as join, o as isBareImport } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
3
|
+
import { w as withInlineSourceMap, i as isBuiltin, a as isBrowserExternal, t as toBuiltin, s as splitSourceMap } from './moduleSourceMap.Dp1WduWi.js';
|
|
4
|
+
import { i as isInspectorOpen } from './inspector.D6o1NPo1.js';
|
|
4
5
|
import { E as EnvironmentTeardownError, a as getSafeWorkerState } from './utils.DYj33du9.js';
|
|
5
6
|
import { pathToFileURL, URL as URL$1 } from 'node:url';
|
|
6
7
|
import { distDir } from '../path.js';
|
|
@@ -153,8 +154,8 @@ class BareModuleMocker {
|
|
|
153
154
|
getDependencyMockByUrl(url) {
|
|
154
155
|
return this.getMockerRegistry().get(url);
|
|
155
156
|
}
|
|
156
|
-
findMockRedirect(mockPath, external) {
|
|
157
|
-
return findMockRedirect(this.root, mockPath, external);
|
|
157
|
+
findMockRedirect(mockPath, external, rawId) {
|
|
158
|
+
return findMockRedirect(this.root, mockPath, external, rawId);
|
|
158
159
|
}
|
|
159
160
|
mockObject(object, mockExportsOrModuleType, moduleType) {
|
|
160
161
|
let mockExports;
|
|
@@ -180,7 +181,7 @@ class BareModuleMocker {
|
|
|
180
181
|
if (mockType === "manual") registry.register("manual", originalId, id, url, factory);
|
|
181
182
|
else if (mockType === "autospy") registry.register("autospy", originalId, id, url);
|
|
182
183
|
else {
|
|
183
|
-
const redirect = this.findMockRedirect(id, external);
|
|
184
|
+
const redirect = this.findMockRedirect(id, external, originalId);
|
|
184
185
|
if (redirect) registry.register("redirect", originalId, id, url, redirect);
|
|
185
186
|
else registry.register("automock", originalId, id, url);
|
|
186
187
|
}
|
|
@@ -289,6 +290,7 @@ class VitestMocker extends BareModuleMocker {
|
|
|
289
290
|
// factories that run in the current async context, the innermost is last
|
|
290
291
|
factoryContexts = new AsyncLocalStorage();
|
|
291
292
|
pendingFactories = /* @__PURE__ */ new Map();
|
|
293
|
+
waitListeners = /* @__PURE__ */ new Set();
|
|
292
294
|
constructor(moduleRunner, options) {
|
|
293
295
|
super(options);
|
|
294
296
|
this.moduleRunner = moduleRunner;
|
|
@@ -339,26 +341,47 @@ class VitestMocker extends BareModuleMocker {
|
|
|
339
341
|
*/
|
|
340
342
|
isResolvingMock(mockId) {
|
|
341
343
|
if (!this.pendingFactories.has(mockId)) return false;
|
|
342
|
-
|
|
344
|
+
const factories = this.currentFactories();
|
|
345
|
+
return factories.includes(mockId) || this.waitsForFactories(mockId, factories);
|
|
343
346
|
}
|
|
344
347
|
/**
|
|
345
348
|
* Whether the module is still evaluating and waits for a factory
|
|
346
349
|
* that runs in the current async context.
|
|
347
350
|
*/
|
|
348
351
|
isWaitingForFactory(mod) {
|
|
349
|
-
return !!mod.promise && !mod.evaluated && this.
|
|
352
|
+
return !!mod.promise && !mod.evaluated && this.waitsForFactories(mod.id);
|
|
350
353
|
}
|
|
351
|
-
|
|
352
|
-
|
|
354
|
+
/**
|
|
355
|
+
* Waits for the module evaluation. If the module starts to wait
|
|
356
|
+
* for a factory that waits for it, the factory gets the partial exports.
|
|
357
|
+
*/
|
|
358
|
+
awaitEvaluation(mod, request) {
|
|
359
|
+
if (!mod.promise || mod.evaluated) return request();
|
|
360
|
+
const factories = this.currentFactories();
|
|
361
|
+
if (!factories.length) return request();
|
|
362
|
+
let onWait;
|
|
363
|
+
const cycle = new Promise((resolve) => {
|
|
364
|
+
onWait = () => {
|
|
365
|
+
if (this.waitsForFactories(mod.id, factories)) resolve(mod.exports);
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
this.waitListeners.add(onWait);
|
|
369
|
+
return Promise.race([request(), cycle]).finally(() => this.waitListeners.delete(onWait));
|
|
370
|
+
}
|
|
371
|
+
currentFactories() {
|
|
372
|
+
return (this.factoryContexts.getStore() ?? []).map((context) => context.mockId);
|
|
373
|
+
}
|
|
374
|
+
waitsForFactories(id, factories = this.currentFactories()) {
|
|
375
|
+
const queue = [...factories];
|
|
353
376
|
const visited = new Set(factories);
|
|
354
377
|
// a factory that waits for the current one makes everything that waits for it wait too
|
|
355
|
-
while (
|
|
356
|
-
const waiting = this.pendingFactories.get(
|
|
378
|
+
while (queue.length) {
|
|
379
|
+
const waiting = this.pendingFactories.get(queue.pop())?.waiting;
|
|
357
380
|
if (waiting?.has(id)) return true;
|
|
358
381
|
waiting?.forEach((waiter) => {
|
|
359
382
|
if (this.pendingFactories.has(waiter) && !visited.has(waiter)) {
|
|
360
383
|
visited.add(waiter);
|
|
361
|
-
|
|
384
|
+
queue.push(waiter);
|
|
362
385
|
}
|
|
363
386
|
});
|
|
364
387
|
}
|
|
@@ -387,6 +410,7 @@ class VitestMocker extends BareModuleMocker {
|
|
|
387
410
|
const pending = this.pendingFactories.get(id);
|
|
388
411
|
if (pending) {
|
|
389
412
|
waiting.forEach((waiter) => pending.waiting.add(waiter));
|
|
413
|
+
this.waitListeners.forEach((onWait) => onWait());
|
|
390
414
|
return pending.promise;
|
|
391
415
|
}
|
|
392
416
|
const factory = {
|
|
@@ -456,7 +480,7 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
|
|
|
456
480
|
const { id, url, external } = await this.resolveId(rawId, importer);
|
|
457
481
|
let mock = this.getDependencyMock(id);
|
|
458
482
|
if (!mock) {
|
|
459
|
-
const redirect = this.findMockRedirect(id, external);
|
|
483
|
+
const redirect = this.findMockRedirect(id, external, rawId);
|
|
460
484
|
if (redirect) mock = new RedirectedModule(rawId, id, rawId, redirect);
|
|
461
485
|
else mock = new AutomockedModule(rawId, id, rawId);
|
|
462
486
|
}
|
|
@@ -525,7 +549,8 @@ class VitestTransport {
|
|
|
525
549
|
return { result: [] };
|
|
526
550
|
if (name !== "fetchModule") return { error: /* @__PURE__ */ new Error(`Unknown method: ${name}. Expected "fetchModule".`) };
|
|
527
551
|
try {
|
|
528
|
-
|
|
552
|
+
const result = await this.options.fetchModule(...data);
|
|
553
|
+
return { result: this.options.inlineSourceMap ? withInlineSourceMap(result) : result };
|
|
529
554
|
} catch (cause) {
|
|
530
555
|
if (cause instanceof EnvironmentTeardownError) {
|
|
531
556
|
const [id, importer] = data;
|
|
@@ -640,8 +665,7 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
|
640
665
|
}
|
|
641
666
|
_cachedRequest(url, module, callstack = [], metadata) {
|
|
642
667
|
this.vitestOptions.getWorkerState().dependencies?.add(module.id);
|
|
643
|
-
|
|
644
|
-
return super.cachedRequest(url, module, callstack, metadata);
|
|
668
|
+
return this.mocker.awaitEvaluation(module, () => super.cachedRequest(url, module, callstack, metadata));
|
|
645
669
|
}
|
|
646
670
|
/**
|
|
647
671
|
* @internal
|
|
@@ -774,25 +798,30 @@ function startVitestModuleRunner(options) {
|
|
|
774
798
|
context: options.context,
|
|
775
799
|
externalModulesExecutor: options.externalModulesExecutor
|
|
776
800
|
} : void 0;
|
|
777
|
-
// A fresh worker pays one
|
|
778
|
-
//
|
|
779
|
-
// them
|
|
780
|
-
// disk and
|
|
781
|
-
//
|
|
782
|
-
//
|
|
783
|
-
//
|
|
784
|
-
// scheduled rerun always sees the fresh transform.
|
|
801
|
+
// A fresh worker pays one sequential `fetch` round-trip per module in its
|
|
802
|
+
// test files' import graphs, even when the server has already processed
|
|
803
|
+
// them. So the module runner asks the server once for everything it has on
|
|
804
|
+
// disk for its first run request, and answers those fetches locally. Modules
|
|
805
|
+
// that only later files import are fetched one by one. Keeping the snapshot
|
|
806
|
+
// for the runner's lifetime is safe because a worker doesn't outlive a run,
|
|
807
|
+
// and the scheduled rerun picks up a file edited during a run.
|
|
785
808
|
let warmModules;
|
|
786
|
-
let warmModulesContext;
|
|
787
809
|
function fetchWarmModules() {
|
|
788
|
-
|
|
789
|
-
if (warmModulesContext !== workerState.ctx) {
|
|
790
|
-
warmModulesContext = workerState.ctx;
|
|
791
|
-
warmModules = rpc().fetchWarmModules(environment(), workerState.ctx.files.map((file) => file.filepath)).catch(() => null);
|
|
792
|
-
}
|
|
810
|
+
warmModules ??= rpc().fetchWarmModules(environment(), state().ctx.files.map((file) => file.filepath)).catch(() => null);
|
|
793
811
|
return warmModules;
|
|
794
812
|
}
|
|
795
|
-
|
|
813
|
+
// setup files are re-evaluated before every test file, so a reused worker
|
|
814
|
+
// resolves them and their `vi.mock` paths again each time
|
|
815
|
+
const resolvedIds = /* @__PURE__ */ new Map();
|
|
816
|
+
async function resolveId(id, importer) {
|
|
817
|
+
const key = `${environment()}\0${importer ?? ""}\0${id}`;
|
|
818
|
+
if (resolvedIds.has(key)) return resolvedIds.get(key);
|
|
819
|
+
const resolved = rpc().resolve(id, importer, environment());
|
|
820
|
+
resolvedIds.set(key, resolved);
|
|
821
|
+
resolved.then((value) => resolvedIds.set(key, value), () => resolvedIds.delete(key));
|
|
822
|
+
return resolved;
|
|
823
|
+
}
|
|
824
|
+
const evaluator = options.evaluator || new VitestModuleEvaluator({
|
|
796
825
|
traces,
|
|
797
826
|
metaEnv: state().metaEnv,
|
|
798
827
|
evaluatedModules: options.evaluatedModules,
|
|
@@ -808,7 +837,7 @@ function startVitestModuleRunner(options) {
|
|
|
808
837
|
getCurrentTestFilepath: () => state().filepath,
|
|
809
838
|
getEnvironmentName: environment,
|
|
810
839
|
getterTracker: state().getterTracker
|
|
811
|
-
});
|
|
840
|
+
}, vm);
|
|
812
841
|
const moduleRunner = new VitestModuleRunner({
|
|
813
842
|
spyModule: options.spyModule,
|
|
814
843
|
evaluatedModules: options.evaluatedModules,
|
|
@@ -816,6 +845,10 @@ function startVitestModuleRunner(options) {
|
|
|
816
845
|
traces,
|
|
817
846
|
mocker: options.mocker,
|
|
818
847
|
transport: {
|
|
848
|
+
get inlineSourceMap() {
|
|
849
|
+
// a debugger attached to the main process can attach to worker threads too
|
|
850
|
+
return state().config.inspector.openInMainProcess || isInspectorOpen();
|
|
851
|
+
},
|
|
819
852
|
async fetchModule(id, importer, options) {
|
|
820
853
|
const resolvingModules = state().resolvingModules;
|
|
821
854
|
if (isWindows) {
|
|
@@ -870,8 +903,10 @@ function startVitestModuleRunner(options) {
|
|
|
870
903
|
const warmResult = warm && (Object.hasOwn(warm, id) ? warm[id] : Object.hasOwn(warm, rawId) ? warm[rawId] : void 0);
|
|
871
904
|
if (warmResult) {
|
|
872
905
|
if ("tmp" in warmResult) try {
|
|
906
|
+
const { code, sourceMap } = splitSourceMap(readFileSync(warmResult.tmp, "utf-8"));
|
|
873
907
|
return {
|
|
874
|
-
code
|
|
908
|
+
code,
|
|
909
|
+
sourceMap,
|
|
875
910
|
...warmResult
|
|
876
911
|
};
|
|
877
912
|
} catch {}
|
|
@@ -880,10 +915,14 @@ function startVitestModuleRunner(options) {
|
|
|
880
915
|
}
|
|
881
916
|
const otelCarrier = traces?.getContextCarrier();
|
|
882
917
|
const result = await trackFetchTime(rpc().fetch(id, importer, environment(), options, otelCarrier));
|
|
883
|
-
if ("cached" in result)
|
|
884
|
-
code
|
|
885
|
-
|
|
886
|
-
|
|
918
|
+
if ("cached" in result) {
|
|
919
|
+
const { code, sourceMap } = splitSourceMap(readFileSync(result.tmp, "utf-8"));
|
|
920
|
+
return {
|
|
921
|
+
code,
|
|
922
|
+
sourceMap,
|
|
923
|
+
...result
|
|
924
|
+
};
|
|
925
|
+
}
|
|
887
926
|
return result;
|
|
888
927
|
} catch (cause) {
|
|
889
928
|
// rethrow vite error if it cannot load the module because it's not resolved
|
|
@@ -897,9 +936,7 @@ function startVitestModuleRunner(options) {
|
|
|
897
936
|
resolvingModules.delete(rawId);
|
|
898
937
|
}
|
|
899
938
|
},
|
|
900
|
-
resolveId
|
|
901
|
-
return rpc().resolve(id, importer, environment());
|
|
902
|
-
}
|
|
939
|
+
resolveId
|
|
903
940
|
},
|
|
904
941
|
getWorkerState: state,
|
|
905
942
|
vm,
|
|
@@ -1620,7 +1657,8 @@ var node = {
|
|
|
1620
1657
|
configurable: true,
|
|
1621
1658
|
enumerable: descriptor.enumerable,
|
|
1622
1659
|
value: val,
|
|
1623
|
-
|
|
1660
|
+
// accessor globals like `performance` and `localStorage` (Node 25+) are assignable when they have a setter
|
|
1661
|
+
writable: descriptor.writable === true || typeof descriptor.set === "function"
|
|
1624
1662
|
});
|
|
1625
1663
|
return val;
|
|
1626
1664
|
},
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
import { D as DecodedMap } from './source-map.DPHGMWvM.js';
|
|
2
|
+
import { EvaluatedModules } from 'vite/module-runner';
|
|
3
|
+
import { d as dirname, r as resolve } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
4
|
+
|
|
5
|
+
class VitestEvaluatedModules extends EvaluatedModules {
|
|
6
|
+
getModuleSourceMapById(id) {
|
|
7
|
+
const mod = this.getModuleById(id);
|
|
8
|
+
const sourceMap = (mod?.meta)?.sourceMap;
|
|
9
|
+
if (mod && sourceMap) {
|
|
10
|
+
mod.map ??= new DecodedMap(JSON.parse(sourceMap), mod.file);
|
|
11
|
+
return mod.map;
|
|
12
|
+
}
|
|
13
|
+
// TODO: this is not needed in Vite 7.2+
|
|
14
|
+
/** the return type is not exposed by Vite */
|
|
15
|
+
const map = super.getModuleSourceMapById(id);
|
|
16
|
+
if (map != null && !("_patched" in map)) {
|
|
17
|
+
map._patched = true;
|
|
18
|
+
const dir = dirname(map.url);
|
|
19
|
+
map.resolvedSources = (map.map.sources || []).map((s) => resolve(dir, s || ""));
|
|
20
|
+
}
|
|
21
|
+
return map;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
1
25
|
//#region src/utils.ts
|
|
2
26
|
function createPromiseWithResolvers() {
|
|
3
27
|
let resolve;
|
|
@@ -197,4 +221,4 @@ function createBirpc($functions, options) {
|
|
|
197
221
|
return rpc;
|
|
198
222
|
}
|
|
199
223
|
|
|
200
|
-
export { createBirpc as c };
|
|
224
|
+
export { VitestEvaluatedModules as V, createBirpc as c };
|