vitest 5.1.0-beta.1 → 5.1.0
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 +6 -5
- package/dist/browser.js +6 -6
- package/dist/chunks/{base.PJyN9N0u.js → base.Cof-UHJf.js} +14 -19
- package/dist/chunks/{browser.d.D7a15z82.d.ts → browser.d.C7tWgUvw.d.ts} +3 -3
- package/dist/chunks/{cac.Ccf5Je_F.js → cac.BYbt0aJp.js} +22 -20
- package/dist/chunks/{cli-api.DE22LIzq.js → cli-api.COfZo8lK.js} +714 -73
- package/dist/chunks/{config.d.BgktgHfG.d.ts → config.d.B3YV4t0O.d.ts} +37 -2
- package/dist/chunks/{console.DrMPSuFo.js → console.CQZ877Hi.js} +2 -2
- 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.DHWmytIK.js} +10 -10
- package/dist/chunks/{doctor.CPlMs7-y.js → doctor.B-oPbwps.js} +2 -2
- package/dist/chunks/{environment.d.CbTLsZSj.d.ts → environment.d.BFQtFKdZ.d.ts} +1 -1
- package/dist/chunks/{globals.TipXUFcZ.js → globals.ZKtKSkEf.js} +6 -5
- package/dist/chunks/{index.BFXLpwll.js → index.Bi0NXYPf.js} +58 -32
- package/dist/chunks/{index.BXttT2gP.js → index.CZzC1gGg.js} +265 -425
- package/dist/chunks/{index.D14IAvnE.js → index.Di8au7q4.js} +68 -62
- package/dist/chunks/{index.B03wg4V0.js → index.w_oBZ9N8.js} +5 -5
- package/dist/chunks/{init-forks.BL1E3__4.js → init-forks.BaDXQSD8.js} +1 -1
- package/dist/chunks/{init-threads.CYXAGzKQ.js → init-threads.ZX_Vov0z.js} +1 -1
- package/dist/chunks/{init.DVorxUyL.js → init.CO4AB7HZ.js} +4 -4
- package/dist/chunks/{module-dependencies.CwNPkcV4.js → module-dependencies._2Eei3FO.js} +1 -1
- package/dist/chunks/{native.cdzHIdmv.js → native.upB-V0CK.js} +1 -1
- package/dist/chunks/{nativeModuleMocker.3uBcOd84.js → nativeModuleMocker.Dh5azSB4.js} +3 -3
- 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.LRFSN46m.d.ts} +90 -19
- package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
- package/dist/chunks/{resolver.CtCcxIy1.js → resolver.BzpmeQeT.js} +1 -1
- package/dist/chunks/{rpc.BV0XpJ5q.js → rpc.Uhkwr2NM.js} +2 -2
- package/dist/chunks/{rpc.d.DGFP7vWr.d.ts → rpc.d.3FOhdFx8.d.ts} +1 -1
- package/dist/chunks/{run.BfrMbGVD.js → run.CjdgFZiW.js} +7 -4
- package/dist/chunks/{setup-common.llxJkJaD.js → setup-common.CqAQCXzx.js} +2 -2
- package/dist/chunks/{source-map.BjWcsIL9.js → source-map.DakdQc29.js} +11 -13
- package/dist/chunks/{source-map.d.C5A_Tr6V.d.ts → source-map.d.BkG8YK_3.d.ts} +1 -1
- package/dist/chunks/{task-utils.d.BUh7ylUT.d.ts → task-utils.d.D-gFPNFi.d.ts} +1 -1
- package/dist/chunks/{utils.DSfl_w8V.js → utils.BBk_icFG.js} +6 -3
- package/dist/chunks/{vm.Cwj01UFE.js → vm.b4MbCAJQ.js} +15 -13
- package/dist/chunks/{worker.d.gsA26mmR.d.ts → worker.d.CyJRpyfZ.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 +6 -5
- package/dist/module-evaluator.d.ts +2 -2
- package/dist/node.d.ts +10 -10
- package/dist/node.js +15 -13
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +4 -4
- package/dist/task-utils.js +7 -3
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +14 -13
- package/dist/workers/forks.js +15 -14
- package/dist/workers/runVmTests.js +13 -10
- package/dist/workers/threads.js +15 -14
- package/dist/workers/vmForks.js +10 -10
- package/dist/workers/vmThreads.js +10 -10
- package/package.json +15 -15
|
@@ -284,6 +284,32 @@ interface RawSnapshotInfo {
|
|
|
284
284
|
readonly?: boolean;
|
|
285
285
|
content?: string;
|
|
286
286
|
}
|
|
287
|
+
interface RawSnapshot extends RawSnapshotInfo {
|
|
288
|
+
snapshot: string;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
interface InlineSnapshot {
|
|
292
|
+
snapshot: string;
|
|
293
|
+
testId: string;
|
|
294
|
+
file: string;
|
|
295
|
+
line: number;
|
|
296
|
+
column: number;
|
|
297
|
+
assertionName?: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
interface InlineSnapshotUpdate extends InlineSnapshot {
|
|
301
|
+
type: "inline";
|
|
302
|
+
}
|
|
303
|
+
interface FileSnapshotUpdate {
|
|
304
|
+
type: "file";
|
|
305
|
+
file: string;
|
|
306
|
+
key: string;
|
|
307
|
+
snapshot: string;
|
|
308
|
+
}
|
|
309
|
+
interface RawSnapshotUpdate extends RawSnapshot {
|
|
310
|
+
type: "raw";
|
|
311
|
+
}
|
|
312
|
+
type SnapshotUpdate = InlineSnapshotUpdate | FileSnapshotUpdate | RawSnapshotUpdate;
|
|
287
313
|
|
|
288
314
|
interface SnapshotEnvironment {
|
|
289
315
|
getVersion: () => string;
|
|
@@ -321,6 +347,7 @@ interface SnapshotReturnOptions {
|
|
|
321
347
|
expected?: string;
|
|
322
348
|
key: string;
|
|
323
349
|
pass: boolean;
|
|
350
|
+
update?: SnapshotUpdate;
|
|
324
351
|
}
|
|
325
352
|
interface SaveStatus {
|
|
326
353
|
deleted: boolean;
|
|
@@ -373,6 +400,7 @@ declare class SnapshotState {
|
|
|
373
400
|
private _resolveKey;
|
|
374
401
|
private _resolveInlineStack;
|
|
375
402
|
private _reconcile;
|
|
403
|
+
private _createUpdate;
|
|
376
404
|
save(): Promise<SaveStatus>;
|
|
377
405
|
getUncheckedCount(): number;
|
|
378
406
|
getUncheckedKeys(): Array<string>;
|
|
@@ -3426,6 +3454,10 @@ interface FailureScreenshotArtifactAttachment extends TestAttachment {
|
|
|
3426
3454
|
interface FailureScreenshotArtifact extends TestArtifactBase {
|
|
3427
3455
|
type: "internal:failureScreenshot";
|
|
3428
3456
|
attachments: [FailureScreenshotArtifactAttachment] | [];
|
|
3457
|
+
/** The zero-based retry index of the attempt that took the screenshot. */
|
|
3458
|
+
retryIndex?: number;
|
|
3459
|
+
/** The zero-based repeat index of the attempt that took the screenshot. */
|
|
3460
|
+
repeatIndex?: number;
|
|
3429
3461
|
}
|
|
3430
3462
|
/**
|
|
3431
3463
|
* @experimental
|
|
@@ -3768,6 +3800,7 @@ interface SerializedConfig {
|
|
|
3768
3800
|
trace: BrowserTraceViewMode;
|
|
3769
3801
|
traceView: {
|
|
3770
3802
|
enabled: boolean;
|
|
3803
|
+
mode: BrowserTraceViewRecordingMode;
|
|
3771
3804
|
recordCanvas: boolean;
|
|
3772
3805
|
inlineImages: boolean;
|
|
3773
3806
|
ariaSnapshot: boolean;
|
|
@@ -3802,6 +3835,7 @@ interface SerializedConfig {
|
|
|
3802
3835
|
viteModuleRunner: boolean;
|
|
3803
3836
|
nodeLoader: boolean;
|
|
3804
3837
|
recordDependencies: boolean;
|
|
3838
|
+
traceTimeline: boolean;
|
|
3805
3839
|
openTelemetry: {
|
|
3806
3840
|
enabled: boolean;
|
|
3807
3841
|
sdkPath?: string;
|
|
@@ -3832,7 +3866,8 @@ type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookT
|
|
|
3832
3866
|
};
|
|
3833
3867
|
};
|
|
3834
3868
|
type RuntimeOptions = Partial<RuntimeConfig>;
|
|
3869
|
+
type BrowserTraceViewRecordingMode = "off" | "on" | "failure-only";
|
|
3835
3870
|
type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
|
|
3836
3871
|
|
|
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,
|
|
3872
|
+
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 };
|
|
3873
|
+
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, FetchCachedFileSystemResult as bw, ResolveFunctionResult as bx, 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.DakdQc29.js';
|
|
5
5
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
6
6
|
import { g as getWorkerState, E as EnvironmentTeardownError } from './utils.DYj33du9.js';
|
|
7
7
|
import './index.D0heQG4v.js';
|
|
8
|
-
import './pathe.M-eThtNZ.
|
|
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.Di8au7q4.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';
|
|
@@ -31,24 +31,24 @@ import 'node:stream';
|
|
|
31
31
|
import './display.BlTmubjj.js';
|
|
32
32
|
import './index.D0heQG4v.js';
|
|
33
33
|
import 'node:perf_hooks';
|
|
34
|
-
import './source-map.
|
|
35
|
-
import './run.
|
|
34
|
+
import './source-map.DakdQc29.js';
|
|
35
|
+
import './run.CjdgFZiW.js';
|
|
36
36
|
import '../task-utils.js';
|
|
37
37
|
import 'obug';
|
|
38
|
-
import './resolver.
|
|
38
|
+
import './resolver.BzpmeQeT.js';
|
|
39
39
|
import 'es-module-lexer';
|
|
40
40
|
import './offset.Dy-5Fdfn.js';
|
|
41
|
-
import './utils.
|
|
41
|
+
import './utils.BBk_icFG.js';
|
|
42
42
|
import '#module-evaluator';
|
|
43
43
|
import 'picomatch';
|
|
44
|
-
import './module-dependencies.
|
|
45
|
-
import './coverage.
|
|
44
|
+
import './module-dependencies._2Eei3FO.js';
|
|
45
|
+
import './coverage.jGCktcGP.js';
|
|
46
46
|
import 'node:tty';
|
|
47
47
|
import 'node:events';
|
|
48
48
|
import './index.DmDMHCg8.js';
|
|
49
49
|
import 'node:child_process';
|
|
50
50
|
import 'node:worker_threads';
|
|
51
|
-
import './cac.
|
|
51
|
+
import './cac.BYbt0aJp.js';
|
|
52
52
|
import 'events';
|
|
53
53
|
import 'readline';
|
|
54
54
|
|
|
@@ -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.COfZo8lK.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,18 +1,19 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.DLYM6cZY.js';
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './run.
|
|
2
|
+
import { i as index } from './index.CZzC1gGg.js';
|
|
3
|
+
import './run.CjdgFZiW.js';
|
|
4
4
|
import './index.D0heQG4v.js';
|
|
5
5
|
import './tinyrainbow.Do8I1XRG.js';
|
|
6
6
|
import './display.BlTmubjj.js';
|
|
7
|
-
import './pathe.M-eThtNZ.
|
|
8
|
-
import './source-map.
|
|
7
|
+
import './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
8
|
+
import './source-map.DakdQc29.js';
|
|
9
9
|
import '../task-utils.js';
|
|
10
10
|
import './utils.DYj33du9.js';
|
|
11
11
|
import './spy.DDMXghXv.js';
|
|
12
12
|
import 'chai';
|
|
13
13
|
import './plugins.DPQHVT0p.js';
|
|
14
|
+
import './rawSnapshot.DqSiqIEx.js';
|
|
14
15
|
import './offset.Dy-5Fdfn.js';
|
|
15
|
-
import './rpc.
|
|
16
|
+
import './rpc.Uhkwr2NM.js';
|
|
16
17
|
import 'vite/module-runner';
|
|
17
18
|
import './index.DmDMHCg8.js';
|
|
18
19
|
import 'tinybench';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs__default from 'node:fs';
|
|
2
|
-
import { n as normalize,
|
|
2
|
+
import { n as normalize, m as splitFileAndPostfix$1, j as join, o as isBareImport } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
3
3
|
import { i as isBuiltin, a as isBrowserExternal, t as toBuiltin } from './modules.BJuCwlRJ.js';
|
|
4
4
|
import { E as EnvironmentTeardownError, a as getSafeWorkerState } from './utils.DYj33du9.js';
|
|
5
5
|
import { pathToFileURL, URL as URL$1 } from 'node:url';
|
|
@@ -153,8 +153,8 @@ class BareModuleMocker {
|
|
|
153
153
|
getDependencyMockByUrl(url) {
|
|
154
154
|
return this.getMockerRegistry().get(url);
|
|
155
155
|
}
|
|
156
|
-
findMockRedirect(mockPath, external) {
|
|
157
|
-
return findMockRedirect(this.root, mockPath, external);
|
|
156
|
+
findMockRedirect(mockPath, external, rawId) {
|
|
157
|
+
return findMockRedirect(this.root, mockPath, external, rawId);
|
|
158
158
|
}
|
|
159
159
|
mockObject(object, mockExportsOrModuleType, moduleType) {
|
|
160
160
|
let mockExports;
|
|
@@ -180,7 +180,7 @@ class BareModuleMocker {
|
|
|
180
180
|
if (mockType === "manual") registry.register("manual", originalId, id, url, factory);
|
|
181
181
|
else if (mockType === "autospy") registry.register("autospy", originalId, id, url);
|
|
182
182
|
else {
|
|
183
|
-
const redirect = this.findMockRedirect(id, external);
|
|
183
|
+
const redirect = this.findMockRedirect(id, external, originalId);
|
|
184
184
|
if (redirect) registry.register("redirect", originalId, id, url, redirect);
|
|
185
185
|
else registry.register("automock", originalId, id, url);
|
|
186
186
|
}
|
|
@@ -289,6 +289,7 @@ class VitestMocker extends BareModuleMocker {
|
|
|
289
289
|
// factories that run in the current async context, the innermost is last
|
|
290
290
|
factoryContexts = new AsyncLocalStorage();
|
|
291
291
|
pendingFactories = /* @__PURE__ */ new Map();
|
|
292
|
+
waitListeners = /* @__PURE__ */ new Set();
|
|
292
293
|
constructor(moduleRunner, options) {
|
|
293
294
|
super(options);
|
|
294
295
|
this.moduleRunner = moduleRunner;
|
|
@@ -339,26 +340,47 @@ class VitestMocker extends BareModuleMocker {
|
|
|
339
340
|
*/
|
|
340
341
|
isResolvingMock(mockId) {
|
|
341
342
|
if (!this.pendingFactories.has(mockId)) return false;
|
|
342
|
-
|
|
343
|
+
const factories = this.currentFactories();
|
|
344
|
+
return factories.includes(mockId) || this.waitsForFactories(mockId, factories);
|
|
343
345
|
}
|
|
344
346
|
/**
|
|
345
347
|
* Whether the module is still evaluating and waits for a factory
|
|
346
348
|
* that runs in the current async context.
|
|
347
349
|
*/
|
|
348
350
|
isWaitingForFactory(mod) {
|
|
349
|
-
return !!mod.promise && !mod.evaluated && this.
|
|
351
|
+
return !!mod.promise && !mod.evaluated && this.waitsForFactories(mod.id);
|
|
350
352
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Waits for the module evaluation. If the module starts to wait
|
|
355
|
+
* for a factory that waits for it, the factory gets the partial exports.
|
|
356
|
+
*/
|
|
357
|
+
awaitEvaluation(mod, request) {
|
|
358
|
+
if (!mod.promise || mod.evaluated) return request();
|
|
359
|
+
const factories = this.currentFactories();
|
|
360
|
+
if (!factories.length) return request();
|
|
361
|
+
let onWait;
|
|
362
|
+
const cycle = new Promise((resolve) => {
|
|
363
|
+
onWait = () => {
|
|
364
|
+
if (this.waitsForFactories(mod.id, factories)) resolve(mod.exports);
|
|
365
|
+
};
|
|
366
|
+
});
|
|
367
|
+
this.waitListeners.add(onWait);
|
|
368
|
+
return Promise.race([request(), cycle]).finally(() => this.waitListeners.delete(onWait));
|
|
369
|
+
}
|
|
370
|
+
currentFactories() {
|
|
371
|
+
return (this.factoryContexts.getStore() ?? []).map((context) => context.mockId);
|
|
372
|
+
}
|
|
373
|
+
waitsForFactories(id, factories = this.currentFactories()) {
|
|
374
|
+
const queue = [...factories];
|
|
353
375
|
const visited = new Set(factories);
|
|
354
376
|
// a factory that waits for the current one makes everything that waits for it wait too
|
|
355
|
-
while (
|
|
356
|
-
const waiting = this.pendingFactories.get(
|
|
377
|
+
while (queue.length) {
|
|
378
|
+
const waiting = this.pendingFactories.get(queue.pop())?.waiting;
|
|
357
379
|
if (waiting?.has(id)) return true;
|
|
358
380
|
waiting?.forEach((waiter) => {
|
|
359
381
|
if (this.pendingFactories.has(waiter) && !visited.has(waiter)) {
|
|
360
382
|
visited.add(waiter);
|
|
361
|
-
|
|
383
|
+
queue.push(waiter);
|
|
362
384
|
}
|
|
363
385
|
});
|
|
364
386
|
}
|
|
@@ -387,6 +409,7 @@ class VitestMocker extends BareModuleMocker {
|
|
|
387
409
|
const pending = this.pendingFactories.get(id);
|
|
388
410
|
if (pending) {
|
|
389
411
|
waiting.forEach((waiter) => pending.waiting.add(waiter));
|
|
412
|
+
this.waitListeners.forEach((onWait) => onWait());
|
|
390
413
|
return pending.promise;
|
|
391
414
|
}
|
|
392
415
|
const factory = {
|
|
@@ -456,7 +479,7 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
|
|
|
456
479
|
const { id, url, external } = await this.resolveId(rawId, importer);
|
|
457
480
|
let mock = this.getDependencyMock(id);
|
|
458
481
|
if (!mock) {
|
|
459
|
-
const redirect = this.findMockRedirect(id, external);
|
|
482
|
+
const redirect = this.findMockRedirect(id, external, rawId);
|
|
460
483
|
if (redirect) mock = new RedirectedModule(rawId, id, rawId, redirect);
|
|
461
484
|
else mock = new AutomockedModule(rawId, id, rawId);
|
|
462
485
|
}
|
|
@@ -640,8 +663,7 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
|
|
|
640
663
|
}
|
|
641
664
|
_cachedRequest(url, module, callstack = [], metadata) {
|
|
642
665
|
this.vitestOptions.getWorkerState().dependencies?.add(module.id);
|
|
643
|
-
|
|
644
|
-
return super.cachedRequest(url, module, callstack, metadata);
|
|
666
|
+
return this.mocker.awaitEvaluation(module, () => super.cachedRequest(url, module, callstack, metadata));
|
|
645
667
|
}
|
|
646
668
|
/**
|
|
647
669
|
* @internal
|
|
@@ -774,24 +796,29 @@ function startVitestModuleRunner(options) {
|
|
|
774
796
|
context: options.context,
|
|
775
797
|
externalModulesExecutor: options.externalModulesExecutor
|
|
776
798
|
} : 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.
|
|
799
|
+
// A fresh worker pays one sequential `fetch` round-trip per module in its
|
|
800
|
+
// test files' import graphs, even when the server has already processed
|
|
801
|
+
// them. So the module runner asks the server once for everything it has on
|
|
802
|
+
// disk for its first run request, and answers those fetches locally. Modules
|
|
803
|
+
// that only later files import are fetched one by one. Keeping the snapshot
|
|
804
|
+
// for the runner's lifetime is safe because a worker doesn't outlive a run,
|
|
805
|
+
// and the scheduled rerun picks up a file edited during a run.
|
|
785
806
|
let warmModules;
|
|
786
|
-
let warmModulesContext;
|
|
787
807
|
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
|
-
}
|
|
808
|
+
warmModules ??= rpc().fetchWarmModules(environment(), state().ctx.files.map((file) => file.filepath)).catch(() => null);
|
|
793
809
|
return warmModules;
|
|
794
810
|
}
|
|
811
|
+
// setup files are re-evaluated before every test file, so a reused worker
|
|
812
|
+
// resolves them and their `vi.mock` paths again each time
|
|
813
|
+
const resolvedIds = /* @__PURE__ */ new Map();
|
|
814
|
+
async function resolveId(id, importer) {
|
|
815
|
+
const key = `${environment()}\0${importer ?? ""}\0${id}`;
|
|
816
|
+
if (resolvedIds.has(key)) return resolvedIds.get(key);
|
|
817
|
+
const resolved = rpc().resolve(id, importer, environment());
|
|
818
|
+
resolvedIds.set(key, resolved);
|
|
819
|
+
resolved.then((value) => resolvedIds.set(key, value), () => resolvedIds.delete(key));
|
|
820
|
+
return resolved;
|
|
821
|
+
}
|
|
795
822
|
const evaluator = options.evaluator || new VitestModuleEvaluator(vm, {
|
|
796
823
|
traces,
|
|
797
824
|
metaEnv: state().metaEnv,
|
|
@@ -897,9 +924,7 @@ function startVitestModuleRunner(options) {
|
|
|
897
924
|
resolvingModules.delete(rawId);
|
|
898
925
|
}
|
|
899
926
|
},
|
|
900
|
-
resolveId
|
|
901
|
-
return rpc().resolve(id, importer, environment());
|
|
902
|
-
}
|
|
927
|
+
resolveId
|
|
903
928
|
},
|
|
904
929
|
getWorkerState: state,
|
|
905
930
|
vm,
|
|
@@ -1620,7 +1645,8 @@ var node = {
|
|
|
1620
1645
|
configurable: true,
|
|
1621
1646
|
enumerable: descriptor.enumerable,
|
|
1622
1647
|
value: val,
|
|
1623
|
-
|
|
1648
|
+
// accessor globals like `performance` and `localStorage` (Node 25+) are assignable when they have a setter
|
|
1649
|
+
writable: descriptor.writable === true || typeof descriptor.set === "function"
|
|
1624
1650
|
});
|
|
1625
1651
|
return val;
|
|
1626
1652
|
},
|