vitest 5.1.0 → 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 +6 -5
- package/dist/browser.js +7 -7
- package/dist/chunks/{base.Cof-UHJf.js → base.C2su7_N0.js} +12 -12
- package/dist/chunks/{browser.d.C7tWgUvw.d.ts → browser.d.B-QwH_F6.d.ts} +3 -3
- package/dist/chunks/{cac.BYbt0aJp.js → cac.BK306qhQ.js} +15 -10
- package/dist/chunks/{cli-api.COfZo8lK.js → cli-api.D6E8EtSi.js} +317 -134
- package/dist/chunks/{config.d.B3YV4t0O.d.ts → config.d.BpJq6tRA.d.ts} +7 -1
- package/dist/chunks/{console.CQZ877Hi.js → console.VJUxd1rM.js} +2 -2
- package/dist/chunks/{creator.DHWmytIK.js → creator.CoOCr85O.js} +12 -10
- package/dist/chunks/{display.BlTmubjj.js → display.Cj2h2zsY.js} +1 -1
- package/dist/chunks/{doctor.B-oPbwps.js → doctor.SRjZIZuA.js} +1 -1
- package/dist/chunks/{environment.d.BFQtFKdZ.d.ts → environment.d.rlpAM-ON.d.ts} +1 -1
- package/dist/chunks/{globals.ZKtKSkEf.js → globals.Mxora3_v.js} +10 -10
- package/dist/chunks/{index.Bi0NXYPf.js → index.C7Nn66Gy.js} +21 -9
- package/dist/chunks/{index.DmDMHCg8.js → index.CAmut2NG.js} +25 -1
- package/dist/chunks/{index.CZzC1gGg.js → index.DNcttN5a.js} +31 -20
- package/dist/chunks/{index.w_oBZ9N8.js → index.Da_szXbS.js} +3 -3
- package/dist/chunks/{index.Di8au7q4.js → index.ER9afepi.js} +210 -88
- package/dist/chunks/{index.D0heQG4v.js → index.Or9psEGe.js} +1 -1
- package/dist/chunks/{init-forks.BaDXQSD8.js → init-forks.q4IoGYZe.js} +7 -1
- package/dist/chunks/{init-threads.ZX_Vov0z.js → init-threads.Bf1Frg9S.js} +1 -1
- package/dist/chunks/{init.CO4AB7HZ.js → init.dGO4K2C0.js} +16 -8
- package/dist/chunks/{inspector.CvyFGlXm.js → inspector.D6o1NPo1.js} +12 -1
- package/dist/chunks/{modules.BJuCwlRJ.js → moduleSourceMap.Dp1WduWi.js} +31 -1
- package/dist/chunks/{native.upB-V0CK.js → native.D5q1ylZC.js} +2 -1
- package/dist/chunks/{nativeModuleMocker.Dh5azSB4.js → nativeModuleMocker.ihb3q7Cg.js} +4 -2
- package/dist/chunks/{plugin.d.LRFSN46m.d.ts → plugin.d.Du7hHZwb.d.ts} +32 -29
- package/dist/chunks/{plugins.DPQHVT0p.js → plugins.BPruPOR8.js} +1 -1
- package/dist/chunks/{rawSnapshot.DqSiqIEx.js → rawSnapshot.DvoRLRNr.js} +2 -2
- package/dist/chunks/{rpc.Uhkwr2NM.js → rpc.CNYWPa97.js} +3 -19
- package/dist/chunks/{rpc.d.3FOhdFx8.d.ts → rpc.d.DHfuwqP0.d.ts} +2 -2
- package/dist/chunks/{run.CjdgFZiW.js → run.zBhXlcZQ.js} +113 -49
- package/dist/chunks/{setup-common.CqAQCXzx.js → setup-common.wwc_NYRJ.js} +3 -3
- package/dist/chunks/{source-map.DakdQc29.js → source-map.DPHGMWvM.js} +3 -1
- package/dist/chunks/{source-map.d.BkG8YK_3.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.D-gFPNFi.d.ts → task-utils.d.DgSjIb7r.d.ts} +1 -1
- package/dist/chunks/{utils.BBk_icFG.js → utils.sAsh2ClK.js} +2 -6
- package/dist/chunks/{vm.b4MbCAJQ.js → vm.agn4qnmT.js} +4 -4
- package/dist/chunks/{worker.d.CyJRpyfZ.d.ts → worker.d.BigfbIsH.d.ts} +3 -3
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +8 -8
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +1 -1
- package/dist/node.d.ts +11 -10
- package/dist/node.js +17 -15
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.js +5 -3
- package/dist/spy.js +1 -1
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +19 -18
- package/dist/workers/forks.js +20 -19
- package/dist/workers/runVmTests.js +14 -14
- package/dist/workers/threads.js +20 -19
- package/dist/workers/vmForks.js +14 -13
- package/dist/workers/vmThreads.js +14 -13
- package/dist/workers/watchdog.js +20 -0
- package/package.json +19 -19
|
@@ -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
|
|
|
@@ -684,6 +685,10 @@ interface ResolveFunctionResult {
|
|
|
684
685
|
url: string;
|
|
685
686
|
}
|
|
686
687
|
type ModuleType = "cjs" | "esm";
|
|
688
|
+
type VitestFetchResult = FetchResult & {
|
|
689
|
+
moduleType?: ModuleType;
|
|
690
|
+
sourceMap?: string;
|
|
691
|
+
};
|
|
687
692
|
interface FetchCachedFileSystemResult {
|
|
688
693
|
cached: true;
|
|
689
694
|
tmp: string;
|
|
@@ -3777,6 +3782,7 @@ interface SerializedConfig {
|
|
|
3777
3782
|
port?: number;
|
|
3778
3783
|
host?: string;
|
|
3779
3784
|
waitForDebugger?: boolean;
|
|
3785
|
+
openInMainProcess?: boolean;
|
|
3780
3786
|
};
|
|
3781
3787
|
watch: boolean;
|
|
3782
3788
|
env: Record<string, any>;
|
|
@@ -3870,4 +3876,4 @@ type BrowserTraceViewRecordingMode = "off" | "on" | "failure-only";
|
|
|
3870
3876
|
type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
|
|
3871
3877
|
|
|
3872
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 };
|
|
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,
|
|
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,10 +1,10 @@
|
|
|
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.
|
|
7
|
+
import './index.Or9psEGe.js';
|
|
8
8
|
import './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
9
9
|
|
|
10
10
|
const RealDate = globalThis.Date;
|
|
@@ -2,7 +2,7 @@ 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';
|
|
@@ -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
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
48
|
import './module-dependencies._2Eei3FO.js';
|
|
45
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 = [
|
|
@@ -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,22 +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.
|
|
6
|
+
import './display.Cj2h2zsY.js';
|
|
7
7
|
import './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
8
|
-
import './source-map.
|
|
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.
|
|
14
|
-
import './rawSnapshot.
|
|
13
|
+
import './plugins.BPruPOR8.js';
|
|
14
|
+
import './rawSnapshot.DvoRLRNr.js';
|
|
15
15
|
import './offset.Dy-5Fdfn.js';
|
|
16
|
-
import './
|
|
16
|
+
import './index.CAmut2NG.js';
|
|
17
17
|
import 'vite/module-runner';
|
|
18
|
-
import './index.DmDMHCg8.js';
|
|
19
18
|
import 'tinybench';
|
|
19
|
+
import './rpc.CNYWPa97.js';
|
|
20
20
|
import 'expect-type';
|
|
21
21
|
|
|
22
22
|
function registerApiGlobally() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs__default from 'node:fs';
|
|
2
2
|
import { n as normalize, m as splitFileAndPostfix$1, j as join, o as isBareImport } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
3
|
-
import { i as isBuiltin, a as isBrowserExternal, t as toBuiltin } from './
|
|
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';
|
|
@@ -548,7 +549,8 @@ class VitestTransport {
|
|
|
548
549
|
return { result: [] };
|
|
549
550
|
if (name !== "fetchModule") return { error: /* @__PURE__ */ new Error(`Unknown method: ${name}. Expected "fetchModule".`) };
|
|
550
551
|
try {
|
|
551
|
-
|
|
552
|
+
const result = await this.options.fetchModule(...data);
|
|
553
|
+
return { result: this.options.inlineSourceMap ? withInlineSourceMap(result) : result };
|
|
552
554
|
} catch (cause) {
|
|
553
555
|
if (cause instanceof EnvironmentTeardownError) {
|
|
554
556
|
const [id, importer] = data;
|
|
@@ -819,7 +821,7 @@ function startVitestModuleRunner(options) {
|
|
|
819
821
|
resolved.then((value) => resolvedIds.set(key, value), () => resolvedIds.delete(key));
|
|
820
822
|
return resolved;
|
|
821
823
|
}
|
|
822
|
-
const evaluator = options.evaluator || new VitestModuleEvaluator(
|
|
824
|
+
const evaluator = options.evaluator || new VitestModuleEvaluator({
|
|
823
825
|
traces,
|
|
824
826
|
metaEnv: state().metaEnv,
|
|
825
827
|
evaluatedModules: options.evaluatedModules,
|
|
@@ -835,7 +837,7 @@ function startVitestModuleRunner(options) {
|
|
|
835
837
|
getCurrentTestFilepath: () => state().filepath,
|
|
836
838
|
getEnvironmentName: environment,
|
|
837
839
|
getterTracker: state().getterTracker
|
|
838
|
-
});
|
|
840
|
+
}, vm);
|
|
839
841
|
const moduleRunner = new VitestModuleRunner({
|
|
840
842
|
spyModule: options.spyModule,
|
|
841
843
|
evaluatedModules: options.evaluatedModules,
|
|
@@ -843,6 +845,10 @@ function startVitestModuleRunner(options) {
|
|
|
843
845
|
traces,
|
|
844
846
|
mocker: options.mocker,
|
|
845
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
|
+
},
|
|
846
852
|
async fetchModule(id, importer, options) {
|
|
847
853
|
const resolvingModules = state().resolvingModules;
|
|
848
854
|
if (isWindows) {
|
|
@@ -897,8 +903,10 @@ function startVitestModuleRunner(options) {
|
|
|
897
903
|
const warmResult = warm && (Object.hasOwn(warm, id) ? warm[id] : Object.hasOwn(warm, rawId) ? warm[rawId] : void 0);
|
|
898
904
|
if (warmResult) {
|
|
899
905
|
if ("tmp" in warmResult) try {
|
|
906
|
+
const { code, sourceMap } = splitSourceMap(readFileSync(warmResult.tmp, "utf-8"));
|
|
900
907
|
return {
|
|
901
|
-
code
|
|
908
|
+
code,
|
|
909
|
+
sourceMap,
|
|
902
910
|
...warmResult
|
|
903
911
|
};
|
|
904
912
|
} catch {}
|
|
@@ -907,10 +915,14 @@ function startVitestModuleRunner(options) {
|
|
|
907
915
|
}
|
|
908
916
|
const otelCarrier = traces?.getContextCarrier();
|
|
909
917
|
const result = await trackFetchTime(rpc().fetch(id, importer, environment(), options, otelCarrier));
|
|
910
|
-
if ("cached" in result)
|
|
911
|
-
code
|
|
912
|
-
|
|
913
|
-
|
|
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
|
+
}
|
|
914
926
|
return result;
|
|
915
927
|
} catch (cause) {
|
|
916
928
|
// rethrow vite error if it cannot load the module because it's not resolved
|
|
@@ -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 };
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { b as printDiffOrStringify, d as diff, a as processError, g as getRunningTests, c as getCurrentTest,
|
|
1
|
+
import { b as printDiffOrStringify, d as diff, a as processError, r as replaceAsymmetricMatcher, g as getRunningTests, c as getCurrentTest, e as recordArtifact, T as TestSyntaxError, f as createTaskCollector, h as getCurrentSuite, i as createChainable, j as getHooks, k as getFn, m as matchesTags, l as afterAll, n as afterEach, o as aroundAll, q as aroundEach, t as beforeAll, u as beforeEach, v as describe, w as it, x as onTestFailed, y as onTestFinished, z as suite, A as test } from './run.zBhXlcZQ.js';
|
|
2
2
|
import { i as isChildProcess, r as resetModules, g as getWorkerState } from './utils.DYj33du9.js';
|
|
3
|
-
import { e as parseErrorStacktrace, a as getSafeTimers, f as parseSingleStack, h as delay } from './source-map.
|
|
4
|
-
import { i as isMockFunction, f as fn, a as spyOn, r as restoreAllMocks, b as resetAllMocks, c as clearAllMocks } from './spy.
|
|
5
|
-
import { g as getType, f as isObject, D as noop, y as assertTypes, x as ordinal, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
6
|
-
import { a as commonjsGlobal } from './index.
|
|
7
|
-
import { s as stringify, i as inspect } from './display.
|
|
3
|
+
import { e as parseErrorStacktrace, a as getSafeTimers, f as parseSingleStack, h as delay } from './source-map.DPHGMWvM.js';
|
|
4
|
+
import { i as isMockFunction, f as fn, a as spyOn, r as restoreAllMocks, b as resetAllMocks, c as clearAllMocks } from './spy.BO0hTE3G.js';
|
|
5
|
+
import { g as getType, f as isObject, D as noop, y as assertTypes, x as ordinal, u as deepClone, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
6
|
+
import { a as commonjsGlobal } from './index.Or9psEGe.js';
|
|
7
|
+
import { s as stringify, i as inspect } from './display.Cj2h2zsY.js';
|
|
8
8
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
9
9
|
import * as chai from 'chai';
|
|
10
|
-
import {
|
|
10
|
+
import { util } from 'chai';
|
|
11
11
|
import { getNames, getTests, getTestName, createFileTask } from '../task-utils.js';
|
|
12
|
-
import { a as addSerializer } from './plugins.
|
|
13
|
-
import { C as CounterMap, D as DefaultMap, e as evaluateSnapshotFile, k as keyToTestName, s as saveSnapshotFile, a as saveInlineSnapshots, b as saveRawSnapshots, t as testNameToKey, c as serialize, d as addExtraLineBreaks, n as normalizeNewlines, r as removeExtraLineBreaks, f as deepMergeSnapshot, g as stripSnapshotIndentation } from './rawSnapshot.
|
|
14
|
-
import {
|
|
12
|
+
import { a as addSerializer } from './plugins.BPruPOR8.js';
|
|
13
|
+
import { C as CounterMap, D as DefaultMap, e as evaluateSnapshotFile, k as keyToTestName, s as saveSnapshotFile, a as saveInlineSnapshots, b as saveRawSnapshots, t as testNameToKey, c as serialize, d as addExtraLineBreaks, n as normalizeNewlines, r as removeExtraLineBreaks, f as deepMergeSnapshot, g as stripSnapshotIndentation } from './rawSnapshot.DvoRLRNr.js';
|
|
14
|
+
import { V as VitestEvaluatedModules } from './index.CAmut2NG.js';
|
|
15
15
|
import { Bench } from 'tinybench';
|
|
16
|
+
import { r as rpc } from './rpc.CNYWPa97.js';
|
|
16
17
|
import { expectTypeOf } from 'expect-type';
|
|
17
18
|
|
|
18
19
|
function isSameStackPosition(x, y) {
|
|
@@ -2207,10 +2208,14 @@ const JestChaiExpect = (chai, utils) => {
|
|
|
2207
2208
|
return proxy;
|
|
2208
2209
|
});
|
|
2209
2210
|
};
|
|
2211
|
+
function formatDiff(expected, received) {
|
|
2212
|
+
const { replacedExpected, replacedActual } = replaceAsymmetricMatcher(deepClone(received, { forceWritable: true }), deepClone(expected, { forceWritable: true }));
|
|
2213
|
+
return diff(replacedExpected, replacedActual, { omitAnnotationLines: true });
|
|
2214
|
+
}
|
|
2210
2215
|
function formatCalls(spy, msg, showActualCall) {
|
|
2211
2216
|
if (spy.mock.calls.length) msg += $.gray(`\n\nReceived:\n\n${spy.mock.calls.map((callArg, i) => {
|
|
2212
2217
|
let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`);
|
|
2213
|
-
if (showActualCall) methodCall +=
|
|
2218
|
+
if (showActualCall) methodCall += formatDiff(showActualCall, callArg);
|
|
2214
2219
|
else methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
|
|
2215
2220
|
methodCall += "\n";
|
|
2216
2221
|
return methodCall;
|
|
@@ -2221,7 +2226,7 @@ function formatCalls(spy, msg, showActualCall) {
|
|
|
2221
2226
|
function formatReturns(spy, results, msg, showActualReturn) {
|
|
2222
2227
|
if (results.length) msg += $.gray(`\n\nReceived:\n\n${results.map((callReturn, i) => {
|
|
2223
2228
|
let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call return:\n\n`);
|
|
2224
|
-
if (showActualReturn) methodCall +=
|
|
2229
|
+
if (showActualReturn) methodCall += formatDiff(showActualReturn, callReturn.value);
|
|
2225
2230
|
else methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
|
|
2226
2231
|
methodCall += "\n";
|
|
2227
2232
|
return methodCall;
|
|
@@ -2360,7 +2365,8 @@ function JestExtendPlugin(c, expect, matchers) {
|
|
|
2360
2365
|
}
|
|
2361
2366
|
const JestExtend = (chai, utils) => {
|
|
2362
2367
|
utils.addMethod(chai.expect, "extend", (expect, expects) => {
|
|
2363
|
-
use
|
|
2368
|
+
// not `chai.use`, it keeps every plugin forever
|
|
2369
|
+
JestExtendPlugin(chai, expect, expects)(chai, utils);
|
|
2364
2370
|
});
|
|
2365
2371
|
};
|
|
2366
2372
|
|
|
@@ -7355,7 +7361,7 @@ function throwWithCause(error, source, message) {
|
|
|
7355
7361
|
} catch {}
|
|
7356
7362
|
throw copyStackTrace(error, source);
|
|
7357
7363
|
}
|
|
7358
|
-
function createExpectPoll(expect) {
|
|
7364
|
+
function createExpectPoll(expect, isLocalExpect) {
|
|
7359
7365
|
return function poll(fn, options = {}) {
|
|
7360
7366
|
const defaults = getWorkerState().config.expect?.poll ?? {};
|
|
7361
7367
|
const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
|
|
@@ -7368,7 +7374,8 @@ function createExpectPoll(expect) {
|
|
|
7368
7374
|
chai.util.flag(assertion, "_poll.interval", interval);
|
|
7369
7375
|
const test = chai.util.flag(assertion, "vitest-test");
|
|
7370
7376
|
if (!test) throw new Error("expect.poll() must be called inside a test");
|
|
7371
|
-
|
|
7377
|
+
// the global expect guesses the current test, which is ambiguous while several tests run concurrently
|
|
7378
|
+
if (isLocalExpect || getRunningTests().size === 1) setTraceHandlers(assertion, test);
|
|
7372
7379
|
const proxy = new Proxy(assertion, { get(target, key, receiver) {
|
|
7373
7380
|
const assertionFunction = Reflect.get(target, key, receiver);
|
|
7374
7381
|
if (typeof assertionFunction !== "function") return assertionFunction instanceof chai.Assertion ? proxy : assertionFunction;
|
|
@@ -7924,7 +7931,7 @@ function createExpect(test) {
|
|
|
7924
7931
|
// @ts-expect-error private soft access
|
|
7925
7932
|
return expect(...args).withContext({ soft: true });
|
|
7926
7933
|
};
|
|
7927
|
-
expect.poll = createExpectPoll(expect);
|
|
7934
|
+
expect.poll = createExpectPoll(expect, !!test);
|
|
7928
7935
|
expect.unreachable = (message) => {
|
|
7929
7936
|
chai.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
|
|
7930
7937
|
};
|
|
@@ -7946,11 +7953,11 @@ function createExpect(test) {
|
|
|
7946
7953
|
}
|
|
7947
7954
|
chai.util.addMethod(expect, "assertions", assertions);
|
|
7948
7955
|
chai.util.addMethod(expect, "hasAssertions", hasAssertions);
|
|
7949
|
-
expect.extend(customMatchers);
|
|
7950
|
-
expect.extend(benchMatchers);
|
|
7951
7956
|
return expect;
|
|
7952
7957
|
}
|
|
7953
7958
|
const globalExpect = createExpect();
|
|
7959
|
+
globalExpect.extend(customMatchers);
|
|
7960
|
+
globalExpect.extend(benchMatchers);
|
|
7954
7961
|
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
7955
7962
|
value: globalExpect,
|
|
7956
7963
|
writable: true,
|
|
@@ -8377,15 +8384,19 @@ class TestRunner {
|
|
|
8377
8384
|
if (this.config.experimental.traceTimeline && test.type === "test") startTraceAttempt(test, options);
|
|
8378
8385
|
clearModuleMocks(this.config);
|
|
8379
8386
|
this.snapshotClient.clearTest(test.file.filepath, test.id);
|
|
8380
|
-
|
|
8387
|
+
const assertionState = {
|
|
8381
8388
|
assertionCalls: 0,
|
|
8382
8389
|
isExpectingAssertions: false,
|
|
8383
8390
|
isExpectingAssertionsError: null,
|
|
8384
8391
|
expectedAssertionsNumber: null,
|
|
8385
|
-
expectedAssertionsNumberErrorGen: null
|
|
8392
|
+
expectedAssertionsNumberErrorGen: null
|
|
8393
|
+
};
|
|
8394
|
+
setState({
|
|
8395
|
+
...assertionState,
|
|
8386
8396
|
currentTestName: getTestName(test),
|
|
8387
8397
|
snapshotState: this.snapshotClient.getSnapshotState(test.file.filepath)
|
|
8388
8398
|
}, globalThis[GLOBAL_EXPECT]);
|
|
8399
|
+
if (test.type === "test" && test.context._local) setState(assertionState, test.context.expect);
|
|
8389
8400
|
}
|
|
8390
8401
|
async onAfterRetryTask(test, _options) {
|
|
8391
8402
|
if (this.config.experimental.traceTimeline) await finishTraceAttempt(test);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as chai from 'chai';
|
|
2
2
|
import { createHook } from 'node:async_hooks';
|
|
3
3
|
import { t as takeCoverageInsideWorker } from './coverage.9iqXE2gN.js';
|
|
4
|
-
import { r as rpc } from './rpc.
|
|
5
|
-
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.
|
|
4
|
+
import { r as rpc } from './rpc.CNYWPa97.js';
|
|
5
|
+
import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.wwc_NYRJ.js';
|
|
6
6
|
import { g as getWorkerState } from './utils.DYj33du9.js';
|
|
7
|
-
import { T as TestRunner } from './index.
|
|
7
|
+
import { T as TestRunner } from './index.DNcttN5a.js';
|
|
8
8
|
|
|
9
9
|
function setupChaiConfig(config) {
|
|
10
10
|
Object.assign(chai.config, config);
|