vitest 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +29 -1
- package/browser/context.d.ts +7 -1
- package/browser/context.js +5 -5
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +11 -11
- package/dist/chunks/{base.5tQXSzMP.js → base.CYbb9pQW.js} +39 -15
- package/dist/chunks/{browser.d.g5Thl309.d.ts → browser.d.FGQ9_rK6.d.ts} +3 -3
- package/dist/chunks/{cac.BLbEtnDd.js → cac.DTXWs6Ni.js} +21 -23
- package/dist/chunks/cli-api.Bx28WXzL.js +13879 -0
- package/dist/chunks/{config.d.CU_b-wJj.d.ts → config.d.QBNYCgFU.d.ts} +33 -24
- package/dist/chunks/{console.B09ye7y0.js → console.DtI4yxfN.js} +5 -4
- package/dist/chunks/{coverage.AipniaqB.js → coverage.-bm5IxnW.js} +1 -1
- package/dist/chunks/{coverage.CX7NN5s7.js → coverage.cTDc4uSS.js} +1 -1
- package/dist/chunks/{creator.2VTnpYzN.js → creator.CLL8QFMS.js} +44 -54
- package/dist/chunks/{defaults.D2ip7f-X.js → defaults.B1FCaFfh.js} +2 -2
- package/dist/chunks/{display.pkpxlVcY.js → display.BlTmubjj.js} +1 -1
- package/dist/chunks/{doctor.BCXa6-1R.js → doctor.Bqc8NDDb.js} +40 -41
- package/dist/chunks/{env.DzFJjrmK.js → env.BKKtU2WC.js} +1 -1
- package/dist/chunks/{environment.d.C6xYahWA.d.ts → environment.d.BY56MoGs.d.ts} +1 -1
- package/dist/chunks/{globals.Brdv9iOs.js → globals.CTWMSIPL.js} +10 -10
- package/dist/chunks/{index.C-uw7tH9.js → index.B8VfM7Mf.js} +8606 -20822
- package/dist/chunks/{index.DXQx-kDM.js → index.BoyTG_B7.js} +9 -4
- package/dist/chunks/{index.hTNFpC24.js → index.CPNMO3h-.js} +73 -50
- package/dist/chunks/{index.M2dsQ_UQ.js → index.D0heQG4v.js} +557 -183
- package/dist/chunks/{index.BgwtGYxD.js → index.GYMZ12wH.js} +5 -5
- package/dist/chunks/{index.DGdajAO2.js → index.uwTEEBsB.js} +94 -71
- package/dist/chunks/{init-forks.CdGu3HUy.js → init-forks.CbYYa5xq.js} +1 -1
- package/dist/chunks/{init-threads.2f_lsHNK.js → init-threads.DtjdvxPl.js} +1 -1
- package/dist/chunks/{init.IsjtLXKe.js → init.DrHtV5zd.js} +7 -7
- package/dist/chunks/module-dependencies.CwNPkcV4.js +71 -0
- package/dist/chunks/{native.CF4uT5hY.js → native.cdzHIdmv.js} +48 -34
- package/dist/chunks/{nativeModuleMocker.DwRB4F9R.js → nativeModuleMocker.D8f4cW4A.js} +2 -2
- package/dist/chunks/{nativeModuleRunner.J0QLzNtK.js → nativeModuleRunner.xi64Afb2.js} +1 -1
- package/dist/chunks/{node.CfQ_OGWr.js → node.uQulW0ei.js} +1 -1
- package/dist/chunks/{pathe.M-eThtNZ.DwEga6ro.js → pathe.M-eThtNZ.Ba-7h1rE.js} +9 -7
- package/dist/chunks/{plugin.d.My_z-jmU.d.ts → plugin.d.C8mmycim.d.ts} +109 -68
- package/dist/chunks/{plugins.Cigb0uSy.js → plugins.DPQHVT0p.js} +1 -1
- package/dist/chunks/{resolver.NpfwMKt9.js → resolver.CtCcxIy1.js} +1 -1
- package/dist/chunks/{rpc.CJVl3hZH.js → rpc.DpkUyY1N.js} +3 -2
- package/dist/chunks/{rpc.d.DA9Utv4e.d.ts → rpc.d.Cft1biqy.d.ts} +2 -1
- package/dist/chunks/{run.C5UmxDPh.js → run.Cm2sd7-x.js} +122 -97
- package/dist/chunks/{setup-common.Ct8rQvjH.js → setup-common.BABL3z3m.js} +3 -3
- package/dist/chunks/{source-map.BH0bbrs9.js → source-map.DdKI5IHB.js} +15 -10
- package/dist/chunks/{source-map.d.YqWNcp4e.d.ts → source-map.d.kzFtk_dj.d.ts} +1 -1
- package/dist/chunks/{spy.KLHgXex_.js → spy.DDMXghXv.js} +63 -32
- package/dist/chunks/{task-utils.d.BZm4GSQD.d.ts → task-utils.d.PFh2BV6Q.d.ts} +1 -1
- package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
- package/dist/chunks/{utils.CJ0JImL8.js → utils.DSfl_w8V.js} +44 -42
- package/dist/chunks/{vm.KI2AYADz.js → vm.Uo_C9Uld.js} +16 -13
- package/dist/chunks/{worker.d.MLmnzOJE.d.ts → worker.d.BH-r1bPu.d.ts} +8 -3
- package/dist/cli.js +4 -4
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +9 -10
- package/dist/config.js +2 -2
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/module-evaluator.d.ts +3 -2
- package/dist/module-evaluator.js +8 -5
- package/dist/node.d.ts +9 -10
- package/dist/node.js +27 -26
- package/dist/runtime.d.ts +6 -6
- package/dist/runtime.js +4 -4
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +7 -4
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +21 -20
- package/dist/workers/forks.js +19 -18
- package/dist/workers/runVmTests.js +23 -14
- package/dist/workers/threads.js +19 -18
- package/dist/workers/vmForks.js +13 -13
- package/dist/workers/vmThreads.js +13 -13
- package/globals.d.ts +19 -19
- package/index.cjs +3 -3
- package/optional-runtime-types.d.ts +1 -1
- package/optional-types.d.ts +1 -1
- package/package.json +35 -29
- package/suppress-warnings.cjs +1 -1
- package/dist/chunks/cli-api.DL4Bd7Vh.js +0 -528
- package/dist/chunks/tinyrainbow.Ht9iggcq.js +0 -95
|
@@ -430,6 +430,7 @@ declare class SnapshotState {
|
|
|
430
430
|
private _inlineSnapshotStacks;
|
|
431
431
|
private _testIdToKeys;
|
|
432
432
|
private _rawSnapshots;
|
|
433
|
+
private _rawSnapshotFiles;
|
|
433
434
|
private _uncheckedKeys;
|
|
434
435
|
private _snapshotFormat;
|
|
435
436
|
private _environment;
|
|
@@ -465,6 +466,10 @@ declare class SnapshotState {
|
|
|
465
466
|
probeExpectedSnapshot(options: Pick<SnapshotMatchOptions, "testName" | "testId" | "isInline" | "inlineSnapshot">): ExpectedSnapshot;
|
|
466
467
|
match({ testId, testName, received, key, inlineSnapshot, isInline, error, rawSnapshot, assertionName }: SnapshotMatchOptions): SnapshotReturnOptions;
|
|
467
468
|
processDomainSnapshot({ testId, received, expectedSnapshot, matchResult, isInline, error, assertionName }: ProcessDomainSnapshotOptions): SnapshotReturnOptions;
|
|
469
|
+
/**
|
|
470
|
+
* The snapshot file, if the test file stores snapshots in it, and every asserted file snapshot.
|
|
471
|
+
*/
|
|
472
|
+
getSnapshotFiles(): string[];
|
|
468
473
|
pack(): Promise<SnapshotResult>;
|
|
469
474
|
}
|
|
470
475
|
|
|
@@ -617,10 +622,15 @@ interface UserConsoleLog {
|
|
|
617
622
|
time: number;
|
|
618
623
|
size: number;
|
|
619
624
|
}
|
|
625
|
+
interface ModuleGraphModules {
|
|
626
|
+
[id: string]: {
|
|
627
|
+
external: boolean;
|
|
628
|
+
imports: string[];
|
|
629
|
+
};
|
|
630
|
+
}
|
|
620
631
|
interface ModuleGraphData {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
inlined: string[];
|
|
632
|
+
modules: ModuleGraphModules;
|
|
633
|
+
roots: string[];
|
|
624
634
|
}
|
|
625
635
|
interface ProvidedContext {}
|
|
626
636
|
interface ResolveFunctionResult {
|
|
@@ -649,7 +659,7 @@ interface AsyncLeak {
|
|
|
649
659
|
interface MockResultReturn<T> {
|
|
650
660
|
type: "return";
|
|
651
661
|
/**
|
|
652
|
-
* The value that was returned from the function. If function returned a Promise, then this will be
|
|
662
|
+
* The value that was returned from the function. If the function returned a Promise, then this will be the Promise, not its resolved value.
|
|
653
663
|
*/
|
|
654
664
|
value: T;
|
|
655
665
|
}
|
|
@@ -699,12 +709,12 @@ interface MockContext<T extends Procedure | Constructable = Procedure> {
|
|
|
699
709
|
*/
|
|
700
710
|
calls: MockParameters<T>[];
|
|
701
711
|
/**
|
|
702
|
-
*
|
|
712
|
+
* An array with one value for each call: the object returned by `new`, or the context (`this`) of the call if the mock was called without `new`.
|
|
703
713
|
* @see https://vitest.dev/api/mock#mock-instances
|
|
704
714
|
*/
|
|
705
715
|
instances: MockProcedureContext<T>[];
|
|
706
716
|
/**
|
|
707
|
-
* An array of `this` values that were used during each call to the mock function.
|
|
717
|
+
* An array of `this` values that were used during each call to the mock function. If the mock was called with `new`, the value is the same as in `instances`.
|
|
708
718
|
* @see https://vitest.dev/api/mock#mock-contexts
|
|
709
719
|
*/
|
|
710
720
|
contexts: MockProcedureContext<T>[];
|
|
@@ -757,7 +767,7 @@ interface MockContext<T extends Procedure | Constructable = Procedure> {
|
|
|
757
767
|
/**
|
|
758
768
|
* An array containing all values that were `resolved` or `rejected` from the function.
|
|
759
769
|
*
|
|
760
|
-
*
|
|
770
|
+
* Until the value is resolved or rejected, the type will be `incomplete`.
|
|
761
771
|
*
|
|
762
772
|
* @see https://vitest.dev/api/mock#mock-settledresults
|
|
763
773
|
* @example
|
|
@@ -795,11 +805,11 @@ interface MockContext<T extends Procedure | Constructable = Procedure> {
|
|
|
795
805
|
lastCall: MockParameters<T> | undefined;
|
|
796
806
|
}
|
|
797
807
|
type Procedure = (...args: any[]) => any;
|
|
798
|
-
type NormalizedProcedure<T extends Procedure | Constructable> = T extends Constructable ?
|
|
808
|
+
type NormalizedProcedure<T extends Procedure | Constructable> = T extends Constructable ? {
|
|
799
809
|
new (...args: ConstructorParameters<T>): InstanceType<T>;
|
|
800
|
-
}
|
|
810
|
+
} | {
|
|
801
811
|
(this: InstanceType<T>, ...args: ConstructorParameters<T>): void;
|
|
802
|
-
}
|
|
812
|
+
} : T extends Procedure ? (...args: Parameters<T>) => ReturnType<T> : never;
|
|
803
813
|
type Methods<T> = keyof { [K in keyof T as T[K] extends Procedure ? K : never]: T[K] };
|
|
804
814
|
type Properties<T> = { [K in keyof T]: T[K] extends Procedure ? never : K }[keyof T] & (string | symbol);
|
|
805
815
|
type Classes<T> = { [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never }[keyof T] & (string | symbol);
|
|
@@ -841,7 +851,7 @@ interface MockInstance<T extends Procedure | Constructable = Procedure> extends
|
|
|
841
851
|
*/
|
|
842
852
|
mockRestore(): void;
|
|
843
853
|
/**
|
|
844
|
-
* Returns current
|
|
854
|
+
* Returns current mock implementation if there is one. If an implementation was queued with `mockImplementationOnce`, it returns the first queued implementation instead.
|
|
845
855
|
*
|
|
846
856
|
* If mock was created with `vi.fn`, it will consider passed down method as a mock implementation.
|
|
847
857
|
*
|
|
@@ -900,7 +910,7 @@ interface MockInstance<T extends Procedure | Constructable = Procedure> extends
|
|
|
900
910
|
*/
|
|
901
911
|
mockReturnValue(value: MockReturnType<T>): this;
|
|
902
912
|
/**
|
|
903
|
-
* Accepts a value that will be returned
|
|
913
|
+
* Accepts a value that will be returned during the next function call. TypeScript will only accept values that match the return type of the original function. If chained, each consecutive call will return the specified value.
|
|
904
914
|
*
|
|
905
915
|
* When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
|
|
906
916
|
* @example
|
|
@@ -976,29 +986,29 @@ interface MockInstance<T extends Procedure | Constructable = Procedure> extends
|
|
|
976
986
|
*/
|
|
977
987
|
mockRejectedValueOnce(error: unknown): this;
|
|
978
988
|
}
|
|
979
|
-
type Mock<T extends Procedure | Constructable = Procedure> = MockInstance<T> & (T extends Constructable ?
|
|
989
|
+
type Mock<T extends Procedure | Constructable = Procedure> = MockInstance<T> & (T extends Constructable ? T extends Procedure ? {
|
|
980
990
|
new (...args: ConstructorParameters<T>): InstanceType<T>;
|
|
981
991
|
(...args: Parameters<T>): ReturnType<T>;
|
|
982
992
|
} : {
|
|
983
993
|
new (...args: ConstructorParameters<T>): InstanceType<T>;
|
|
984
|
-
}
|
|
994
|
+
} : {
|
|
985
995
|
new (...args: MockParameters<T>): MockReturnType<T>;
|
|
986
996
|
(...args: MockParameters<T>): MockReturnType<T>;
|
|
987
997
|
}) & { [P in keyof T]: T[P] };
|
|
988
998
|
type PartialMaybePromise<T> = T extends Promise<Awaited<T>> ? Promise<Partial<Awaited<T>>> : Partial<T>;
|
|
989
|
-
type PartialResultFunction<T> = T extends Constructable ?
|
|
999
|
+
type PartialResultFunction<T> = T extends Constructable ? {
|
|
990
1000
|
new (...args: ConstructorParameters<T>): InstanceType<T>;
|
|
991
|
-
}
|
|
1001
|
+
} | {
|
|
992
1002
|
(this: InstanceType<T>, ...args: ConstructorParameters<T>): void;
|
|
993
|
-
}
|
|
1003
|
+
} : T extends Procedure ? (...args: Parameters<T>) => PartialMaybePromise<ReturnType<T>> : T;
|
|
994
1004
|
type PartialMock<T extends Procedure | Constructable = Procedure> = Mock<PartialResultFunction<T extends Mock ? NonNullable<ReturnType<T["getMockImplementation"]>> : T>>;
|
|
995
1005
|
type DeepPartial<T> = T extends Procedure ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
|
|
996
1006
|
type DeepPartialMaybePromise<T> = T extends Promise<Awaited<T>> ? Promise<DeepPartial<Awaited<T>>> : DeepPartial<T>;
|
|
997
|
-
type DeepPartialResultFunction<T> = T extends Constructable ?
|
|
1007
|
+
type DeepPartialResultFunction<T> = T extends Constructable ? {
|
|
998
1008
|
new (...args: ConstructorParameters<T>): InstanceType<T>;
|
|
999
|
-
}
|
|
1009
|
+
} | {
|
|
1000
1010
|
(this: InstanceType<T>, ...args: ConstructorParameters<T>): void;
|
|
1001
|
-
}
|
|
1011
|
+
} : T extends Procedure ? (...args: Parameters<T>) => DeepPartialMaybePromise<ReturnType<T>> : T;
|
|
1002
1012
|
type DeepPartialMock<T extends Procedure | Constructable = Procedure> = Mock<DeepPartialResultFunction<T extends Mock ? NonNullable<ReturnType<T["getMockImplementation"]>> : T>>;
|
|
1003
1013
|
type MaybeMockedConstructor<T> = T extends Constructable ? Mock<T> : T;
|
|
1004
1014
|
type MockedFunction<T extends Procedure | Constructable> = Mock<T> & MockedObject<T>;
|
|
@@ -2452,13 +2462,11 @@ interface TaskResult {
|
|
|
2452
2462
|
*/
|
|
2453
2463
|
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
2454
2464
|
/**
|
|
2455
|
-
* The
|
|
2456
|
-
* failed and `retry` option is set.
|
|
2465
|
+
* The number of times the task has been retried across all repeats.
|
|
2457
2466
|
*/
|
|
2458
2467
|
retryCount?: number;
|
|
2459
2468
|
/**
|
|
2460
|
-
* The
|
|
2461
|
-
* `repeats` option is set. This number also contains `retryCount`.
|
|
2469
|
+
* The zero-based index of the current repeat.
|
|
2462
2470
|
*/
|
|
2463
2471
|
repeatCount?: number;
|
|
2464
2472
|
}
|
|
@@ -3752,6 +3760,7 @@ interface SerializedConfig {
|
|
|
3752
3760
|
};
|
|
3753
3761
|
viteModuleRunner: boolean;
|
|
3754
3762
|
nodeLoader: boolean;
|
|
3763
|
+
recordDependencies: boolean;
|
|
3755
3764
|
openTelemetry: {
|
|
3756
3765
|
enabled: boolean;
|
|
3757
3766
|
sdkPath?: string;
|
|
@@ -1,10 +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.
|
|
5
|
-
import {
|
|
4
|
+
import { a as getSafeTimers } from './source-map.DdKI5IHB.js';
|
|
5
|
+
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
6
6
|
import { g as getWorkerState } from './utils.DYj33du9.js';
|
|
7
|
-
import './
|
|
7
|
+
import './index.D0heQG4v.js';
|
|
8
|
+
import './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
8
9
|
|
|
9
10
|
const RealDate = globalThis.Date;
|
|
10
11
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
@@ -141,7 +142,7 @@ function createCustomConsole(defaultState) {
|
|
|
141
142
|
return new Console({
|
|
142
143
|
stdout,
|
|
143
144
|
stderr,
|
|
144
|
-
colorMode:
|
|
145
|
+
colorMode: $.isColorSupported,
|
|
145
146
|
groupIndentation: 2
|
|
146
147
|
});
|
|
147
148
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveCoverageProviderModule } from './coverage.
|
|
1
|
+
import { r as resolveCoverageProviderModule } from './coverage.cTDc4uSS.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.Ba-7h1rE.js';
|
|
2
2
|
|
|
3
3
|
function getCoverageFilesDirectory(reportsDirectory, shard) {
|
|
4
4
|
return resolve(reportsDirectory, `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`);
|
|
@@ -1,65 +1,55 @@
|
|
|
1
1
|
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
|
-
import { detectPackageManager, installPackage } from './index.
|
|
5
|
-
import {
|
|
4
|
+
import { detectPackageManager, installPackage } from './index.BoyTG_B7.js';
|
|
5
|
+
import { p as prompt, n as findConfigFile } from './index.B8VfM7Mf.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
|
-
import {
|
|
7
|
+
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
8
8
|
import 'node:process';
|
|
9
|
-
import 'node:os';
|
|
10
|
-
import './pathe.M-eThtNZ.DwEga6ro.js';
|
|
11
|
-
import './source-map.BH0bbrs9.js';
|
|
12
|
-
import './cac.BLbEtnDd.js';
|
|
13
|
-
import 'events';
|
|
14
|
-
import './env.DzFJjrmK.js';
|
|
15
|
-
import 'std-env';
|
|
16
|
-
import './constants.-juJ8b_4.js';
|
|
17
|
-
import 'node:assert';
|
|
18
|
-
import 'node:perf_hooks';
|
|
19
|
-
import './index.DmDMHCg8.js';
|
|
20
|
-
import 'https';
|
|
21
|
-
import 'http';
|
|
22
|
-
import 'net';
|
|
23
|
-
import 'tls';
|
|
24
|
-
import 'crypto';
|
|
25
|
-
import 'stream';
|
|
26
|
-
import 'url';
|
|
27
|
-
import 'zlib';
|
|
28
|
-
import 'buffer';
|
|
29
|
-
import 'util';
|
|
30
|
-
import 'vite';
|
|
31
|
-
import 'node:crypto';
|
|
32
|
-
import '../path.js';
|
|
33
9
|
import 'node:url';
|
|
34
|
-
import './
|
|
35
|
-
import './
|
|
36
|
-
import './display.pkpxlVcY.js';
|
|
37
|
-
import '../task-utils.js';
|
|
38
|
-
import './nativeModuleRunner.J0QLzNtK.js';
|
|
10
|
+
import './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
11
|
+
import './nativeModuleRunner.xi64Afb2.js';
|
|
39
12
|
import 'node:module';
|
|
13
|
+
import 'node:assert';
|
|
40
14
|
import 'node:v8';
|
|
41
15
|
import 'node:util';
|
|
42
16
|
import 'vite/module-runner';
|
|
43
|
-
import '../traces.js';
|
|
44
|
-
import 'obug';
|
|
45
|
-
import './resolver.NpfwMKt9.js';
|
|
46
|
-
import 'es-module-lexer';
|
|
47
17
|
import 'tinyglobby';
|
|
48
|
-
import '
|
|
18
|
+
import 'vite';
|
|
19
|
+
import './constants.-juJ8b_4.js';
|
|
20
|
+
import './defaults.B1FCaFfh.js';
|
|
21
|
+
import 'node:os';
|
|
22
|
+
import './env.BKKtU2WC.js';
|
|
23
|
+
import 'std-env';
|
|
24
|
+
import 'node:crypto';
|
|
25
|
+
import '../path.js';
|
|
26
|
+
import './modules.BJuCwlRJ.js';
|
|
49
27
|
import 'magic-string';
|
|
50
28
|
import '@vitest/mocker/node';
|
|
51
29
|
import 'node:console';
|
|
52
30
|
import 'node:stream';
|
|
31
|
+
import './display.BlTmubjj.js';
|
|
32
|
+
import './index.D0heQG4v.js';
|
|
33
|
+
import 'node:perf_hooks';
|
|
34
|
+
import './source-map.DdKI5IHB.js';
|
|
35
|
+
import './run.Cm2sd7-x.js';
|
|
36
|
+
import '../task-utils.js';
|
|
37
|
+
import 'obug';
|
|
38
|
+
import './resolver.CtCcxIy1.js';
|
|
39
|
+
import 'es-module-lexer';
|
|
53
40
|
import './offset.Dy-5Fdfn.js';
|
|
54
|
-
import './utils.
|
|
41
|
+
import './utils.DSfl_w8V.js';
|
|
55
42
|
import '#module-evaluator';
|
|
56
43
|
import 'picomatch';
|
|
57
|
-
import './
|
|
44
|
+
import './module-dependencies.CwNPkcV4.js';
|
|
45
|
+
import './coverage.cTDc4uSS.js';
|
|
58
46
|
import 'node:tty';
|
|
59
47
|
import 'node:events';
|
|
60
|
-
import './
|
|
48
|
+
import './index.DmDMHCg8.js';
|
|
61
49
|
import 'node:child_process';
|
|
62
50
|
import 'node:worker_threads';
|
|
51
|
+
import './cac.DTXWs6Ni.js';
|
|
52
|
+
import 'events';
|
|
63
53
|
import 'readline';
|
|
64
54
|
|
|
65
55
|
const jsxExample = {
|
|
@@ -386,7 +376,7 @@ async function generateExampleFiles(framework, lang) {
|
|
|
386
376
|
return testPath;
|
|
387
377
|
}
|
|
388
378
|
|
|
389
|
-
//
|
|
379
|
+
// oxlint-disable-next-line no-console
|
|
390
380
|
const log = console.log;
|
|
391
381
|
function getProviderOptions() {
|
|
392
382
|
return Object.entries({
|
|
@@ -509,11 +499,11 @@ function getLanguageOptions() {
|
|
|
509
499
|
}
|
|
510
500
|
async function installPackages(pkgManager, packages) {
|
|
511
501
|
if (!packages.length) {
|
|
512
|
-
log(
|
|
502
|
+
log($.green("✔"), $.bold("All packages are already installed."));
|
|
513
503
|
return;
|
|
514
504
|
}
|
|
515
|
-
log(
|
|
516
|
-
log(
|
|
505
|
+
log($.cyan("◼"), $.bold("Installing packages..."));
|
|
506
|
+
log($.cyan("◼"), packages.join(", "));
|
|
517
507
|
log();
|
|
518
508
|
await installPackage(packages, {
|
|
519
509
|
dev: true,
|
|
@@ -611,7 +601,7 @@ async function updatePkgJsonScripts(pkgJsonPath, vitestScript) {
|
|
|
611
601
|
pkg.scripts["test:browser"] = vitestScript;
|
|
612
602
|
await writeFile(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf-8");
|
|
613
603
|
}
|
|
614
|
-
log(
|
|
604
|
+
log($.green("✔"), "Added \"test:browser\" script to your package.json.");
|
|
615
605
|
}
|
|
616
606
|
function getRunScript(pkgManager) {
|
|
617
607
|
switch (pkgManager) {
|
|
@@ -634,7 +624,7 @@ function getPlaywrightRunArgs(pkgManager) {
|
|
|
634
624
|
}
|
|
635
625
|
}
|
|
636
626
|
async function create() {
|
|
637
|
-
log(
|
|
627
|
+
log($.cyan("◼"), "This utility will help you set up a browser testing environment.\n");
|
|
638
628
|
const pkgJsonPath = resolve(process.cwd(), "package.json");
|
|
639
629
|
const pkg = readPkgJson(pkgJsonPath) || {};
|
|
640
630
|
const dependencies = {
|
|
@@ -702,13 +692,13 @@ async function create() {
|
|
|
702
692
|
browsers
|
|
703
693
|
});
|
|
704
694
|
log(
|
|
705
|
-
|
|
695
|
+
$.green("✔"),
|
|
706
696
|
"Created a new config file for browser tests:",
|
|
707
|
-
|
|
697
|
+
$.bold(relative(process.cwd(), configPath)),
|
|
708
698
|
// TODO: Can we modify the config ourselves?
|
|
709
699
|
"\nSince you already have a Vitest config file, it is recommended to copy the contents of the new file ",
|
|
710
700
|
"into your existing config located at ",
|
|
711
|
-
|
|
701
|
+
$.bold(relative(process.cwd(), rootConfig))
|
|
712
702
|
);
|
|
713
703
|
} else {
|
|
714
704
|
const configPath = resolve(process.cwd(), `vitest.config.${lang}`);
|
|
@@ -719,7 +709,7 @@ async function create() {
|
|
|
719
709
|
provider,
|
|
720
710
|
browsers
|
|
721
711
|
});
|
|
722
|
-
log(
|
|
712
|
+
log($.green("✔"), "Created a config file for browser tests:", $.bold(relative(process.cwd(), configPath)));
|
|
723
713
|
}
|
|
724
714
|
log();
|
|
725
715
|
await updatePkgJsonScripts(pkgJsonPath, scriptCommand);
|
|
@@ -732,7 +722,7 @@ async function create() {
|
|
|
732
722
|
"install",
|
|
733
723
|
"--with-deps"
|
|
734
724
|
];
|
|
735
|
-
log(
|
|
725
|
+
log($.cyan("◼"), `Installing Playwright dependencies with \`${$.bold(command)} ${$.bold(allArgs.join(" "))}\`...`);
|
|
736
726
|
log();
|
|
737
727
|
await x(command, allArgs, { nodeOptions: { stdio: [
|
|
738
728
|
"pipe",
|
|
@@ -742,10 +732,10 @@ async function create() {
|
|
|
742
732
|
}
|
|
743
733
|
log();
|
|
744
734
|
const exampleTestFile = await generateExampleFiles(framework, lang);
|
|
745
|
-
log(
|
|
746
|
-
log(
|
|
735
|
+
log($.green("✔"), "Created example test file in", $.bold(relative(process.cwd(), exampleTestFile)));
|
|
736
|
+
log($.dim(" You can safely delete this file once you have written your own tests."));
|
|
747
737
|
log();
|
|
748
|
-
log(
|
|
738
|
+
log($.cyan("◼"), "All done! Run your tests with", $.bold(getRunScript(pkgManager)));
|
|
749
739
|
}
|
|
750
740
|
|
|
751
741
|
export { create };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os__default from 'node:os';
|
|
2
|
-
import './env.
|
|
2
|
+
import './env.BKKtU2WC.js';
|
|
3
3
|
import { isCI, isAgent } from 'std-env';
|
|
4
4
|
|
|
5
5
|
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
@@ -32,7 +32,7 @@ const coverageConfigDefaults = {
|
|
|
32
32
|
],
|
|
33
33
|
allowExternal: false,
|
|
34
34
|
excludeAfterRemap: false,
|
|
35
|
-
processingConcurrency: Math.min(20, os__default.availableParallelism
|
|
35
|
+
processingConcurrency: Math.min(20, os__default.availableParallelism()),
|
|
36
36
|
ignoreClassMethods: [],
|
|
37
37
|
skipFull: false,
|
|
38
38
|
watermarks: {
|
|
@@ -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.D0heQG4v.js';
|
|
2
2
|
|
|
3
3
|
const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
|
|
4
4
|
const PLUGINS = [
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
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.
|
|
8
|
-
import {
|
|
7
|
+
import { t as toArray, r as resolve } from './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
8
|
+
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
9
9
|
import { distDir } from '../path.js';
|
|
10
10
|
|
|
11
11
|
// custom environments are measured too: the run fails if they lack setupVM
|
|
@@ -100,9 +100,9 @@ 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.Bx28WXzL.js').then(function (n) { return n.g; });
|
|
104
104
|
log();
|
|
105
|
-
log(
|
|
105
|
+
log($.inverse($.bold($.blue(" DOCTOR "))), "resolving the current configuration...");
|
|
106
106
|
const ctx = await prepareVitest({
|
|
107
107
|
...options,
|
|
108
108
|
watch: false,
|
|
@@ -117,8 +117,7 @@ async function doctor(cliFilters, options) {
|
|
|
117
117
|
fsModuleCache: project.config.fsModuleCache === true
|
|
118
118
|
}));
|
|
119
119
|
const fileCount = (await ctx.getRelevantTestSpecifications(cliFilters)).length;
|
|
120
|
-
const
|
|
121
|
-
const effectiveMaxWorkers = typeof configuredMaxWorkers === "number" && configuredMaxWorkers > 0 ? configuredMaxWorkers : Math.max(1, availableParallelism() - 1);
|
|
120
|
+
const effectiveMaxWorkers = ctx.config.maxWorkers;
|
|
122
121
|
await ctx.close();
|
|
123
122
|
// the environments import 'happy-dom' relative to the vitest package (it is
|
|
124
123
|
// a peer dependency), so resolving from here mirrors what a run would do
|
|
@@ -203,17 +202,17 @@ async function doctor(cliFilters, options) {
|
|
|
203
202
|
if (candidates.length === 0) log("The configuration already uses the fastest setup Vitest knows how to compare - measuring it for reference.");
|
|
204
203
|
else {
|
|
205
204
|
log("Measuring alternative configurations by running the test suite under each of them.");
|
|
206
|
-
log(
|
|
205
|
+
log($.dim("Close other heavy programs - the comparison is only as good as the machine is quiet."));
|
|
207
206
|
}
|
|
208
207
|
log();
|
|
209
208
|
// The first baseline run also warms up caches for every following run, so
|
|
210
209
|
// candidates are compared in a warm steady state.
|
|
211
|
-
process.stdout.write(
|
|
210
|
+
process.stdout.write($.dim(` measuring ${baselineTitle}...`));
|
|
212
211
|
const firstRun = await runVitest({});
|
|
213
212
|
if (!firstRun.ok) {
|
|
214
213
|
process.stdout.write("\n");
|
|
215
|
-
log(
|
|
216
|
-
if (firstRun.stderr.trim()) log(
|
|
214
|
+
log($.red("The test suite fails with the current configuration. Fix the failures first - doctor needs a green suite to compare configurations."));
|
|
215
|
+
if (firstRun.stderr.trim()) log($.dim(firstRun.stderr.trim()));
|
|
217
216
|
process.exitCode = 1;
|
|
218
217
|
return;
|
|
219
218
|
}
|
|
@@ -229,8 +228,8 @@ async function doctor(cliFilters, options) {
|
|
|
229
228
|
const run = await runVitest({});
|
|
230
229
|
if (!run.ok) {
|
|
231
230
|
process.stdout.write("\n");
|
|
232
|
-
log(
|
|
233
|
-
if (run.stderr.trim()) log(
|
|
231
|
+
log($.red(`The test suite passed once but failed on repetition ${i + 1} with the same configuration - doctor needs a stable green suite to compare configurations.`));
|
|
232
|
+
if (run.stderr.trim()) log($.dim(run.stderr.trim()));
|
|
234
233
|
process.exitCode = 1;
|
|
235
234
|
return;
|
|
236
235
|
}
|
|
@@ -243,7 +242,7 @@ async function doctor(cliFilters, options) {
|
|
|
243
242
|
const candidateTimeout = Math.max(6e4, baselineWall * 4);
|
|
244
243
|
const measured = [];
|
|
245
244
|
for (const candidate of candidates) {
|
|
246
|
-
process.stdout.write(
|
|
245
|
+
process.stdout.write($.dim(` measuring ${candidate.title}...`));
|
|
247
246
|
let wall = Number.POSITIVE_INFINITY;
|
|
248
247
|
let ok = true;
|
|
249
248
|
let stderr = "";
|
|
@@ -294,7 +293,7 @@ async function doctor(cliFilters, options) {
|
|
|
294
293
|
stderr,
|
|
295
294
|
isolationVerdict
|
|
296
295
|
});
|
|
297
|
-
process.stdout.write(ok ? ` ${formatSeconds(wall)}\n` : ` ${
|
|
296
|
+
process.stdout.write(ok ? ` ${formatSeconds(wall)}\n` : ` ${$.red("failed")}\n`);
|
|
298
297
|
}
|
|
299
298
|
const viable = measured.filter((result) => result.ok && result.isolationVerdict !== "failed" && result.wall < baselineWall * .9);
|
|
300
299
|
// among candidates close to the fastest, prefer the one that keeps per-file
|
|
@@ -316,7 +315,7 @@ async function doctor(cliFilters, options) {
|
|
|
316
315
|
let currentBest = preferred ? preferred.wall : baselineWall;
|
|
317
316
|
let probe = Math.floor(effectiveMaxWorkers / 2);
|
|
318
317
|
while (probe >= 2 && probe < fileCount) {
|
|
319
|
-
process.stdout.write(
|
|
318
|
+
process.stdout.write($.dim(` measuring maxWorkers: ${probe}${workerSuffix}...`));
|
|
320
319
|
let wall = Number.POSITIVE_INFINITY;
|
|
321
320
|
let ok = true;
|
|
322
321
|
for (let i = 0; i < reps && ok; i++) {
|
|
@@ -330,7 +329,7 @@ async function doctor(cliFilters, options) {
|
|
|
330
329
|
wall = Math.min(wall, run.wall);
|
|
331
330
|
ok = run.ok;
|
|
332
331
|
}
|
|
333
|
-
process.stdout.write(ok ? ` ${formatSeconds(wall)}\n` : ` ${
|
|
332
|
+
process.stdout.write(ok ? ` ${formatSeconds(wall)}\n` : ` ${$.red("failed")}\n`);
|
|
334
333
|
if (!ok) break;
|
|
335
334
|
workerProbes.push({
|
|
336
335
|
workers: probe,
|
|
@@ -346,15 +345,15 @@ async function doctor(cliFilters, options) {
|
|
|
346
345
|
}
|
|
347
346
|
}
|
|
348
347
|
log();
|
|
349
|
-
log(
|
|
348
|
+
log($.bold("Results") + $.dim(` (min of ${reps} run${reps === 1 ? "" : "s"} each)`));
|
|
350
349
|
log();
|
|
351
350
|
const rowTitles = [...measured.map((m) => m.candidate.title), ...workerProbes.map((p) => `maxWorkers: ${p.workers}${workerSuffix}`)];
|
|
352
351
|
const width = Math.max(baselineTitle.length, ...rowTitles.map((title) => title.length)) + 2;
|
|
353
352
|
log(` ${baselineTitle.padEnd(width)}${formatSeconds(baselineWall)}`);
|
|
354
353
|
for (const result of measured) {
|
|
355
354
|
const title = result.candidate.title.padEnd(width);
|
|
356
|
-
if (!result.ok) log(` ${title}${
|
|
357
|
-
else if (result.isolationVerdict === "failed") log(` ${title}${formatSeconds(result.wall)} ${
|
|
355
|
+
if (!result.ok) log(` ${title}${$.red("failed")}`);
|
|
356
|
+
else if (result.isolationVerdict === "failed") log(` ${title}${formatSeconds(result.wall)} ${$.red("(fails with a shuffled file order - tests depend on isolation)")}`);
|
|
358
357
|
else log(` ${title}${formatSeconds(result.wall)} ${formatDelta(result.wall, baselineWall)}`);
|
|
359
358
|
}
|
|
360
359
|
for (const probeResult of workerProbes) log(` ${`maxWorkers: ${probeResult.workers}${workerSuffix}`.padEnd(width)}${formatSeconds(probeResult.wall)} ${formatDelta(probeResult.wall, baselineWall)}`);
|
|
@@ -364,34 +363,34 @@ async function doctor(cliFilters, options) {
|
|
|
364
363
|
else if (result.isolationVerdict === "failed") logFailureExcerpt(`${result.candidate.title} failed with a shuffled file order:`, result.stderr);
|
|
365
364
|
log();
|
|
366
365
|
if (!preferred && !bestWorkers) {
|
|
367
|
-
if (candidates.length === 0) log(`${
|
|
368
|
-
else log(`${
|
|
366
|
+
if (candidates.length === 0) log(`${$.bold("Recommendation:")} keep the current configuration (${describeProjects(projects)}) - it measured ${$.yellow(formatSeconds(baselineWall))} and Vitest has no faster candidate to suggest for it.`);
|
|
367
|
+
else log(`${$.bold("Recommendation:")} keep the current configuration (${describeProjects(projects)}) - no measured candidate was more than 10% faster.`);
|
|
369
368
|
return;
|
|
370
369
|
}
|
|
371
370
|
const finalWall = bestWorkers ? bestWorkers.wall : preferred.wall;
|
|
372
371
|
const recommendationTitle = [preferred?.candidate.title, bestWorkers ? `maxWorkers: ${bestWorkers.workers}` : void 0].filter(Boolean).join(" + ");
|
|
373
372
|
const configLines = [...preferred ? preferred.candidate.configLines : [], ...bestWorkers ? [`maxWorkers: ${bestWorkers.workers}`] : []];
|
|
374
|
-
log(`${
|
|
373
|
+
log(`${$.bold("Recommendation:")} ${$.yellow(recommendationTitle)} ${formatDelta(finalWall, baselineWall)}`);
|
|
375
374
|
log();
|
|
376
|
-
log(
|
|
377
|
-
log(
|
|
375
|
+
log($.dim(" // vitest.config.ts"));
|
|
376
|
+
log($.dim(` import { defineConfig } from 'vitest/config'`));
|
|
378
377
|
log();
|
|
379
|
-
log(
|
|
380
|
-
log(
|
|
381
|
-
for (const [index, line] of configLines.entries()) log(` ${line},${index === configLines.length - 1 ?
|
|
382
|
-
log(
|
|
383
|
-
log(
|
|
378
|
+
log($.dim(" export default defineConfig({"));
|
|
379
|
+
log($.dim(" test: {"));
|
|
380
|
+
for (const [index, line] of configLines.entries()) log(` ${line},${index === configLines.length - 1 ? $.dim(` // measured ${Math.round((finalWall - baselineWall) / baselineWall * 100)}% on this suite`) : ""}`);
|
|
381
|
+
log($.dim(" },"));
|
|
382
|
+
log($.dim(" })"));
|
|
384
383
|
log();
|
|
385
|
-
if (preferred) for (const note of candidateNotes(preferred)) log(
|
|
384
|
+
if (preferred) for (const note of candidateNotes(preferred)) log($.dim(` ${note}`));
|
|
386
385
|
if (bestWorkers) {
|
|
387
|
-
log(
|
|
388
|
-
log(
|
|
386
|
+
log($.dim(` Fewer workers can be faster because every worker funnels transforms through the`));
|
|
387
|
+
log($.dim(` single main-thread Vite server; a lower count also reduces memory pressure.`));
|
|
389
388
|
}
|
|
390
389
|
if (projects.length > 1) {
|
|
391
390
|
const note = preferred?.candidate.envSwap ? `Doctor swapped the environment of every project running ${preferred.candidate.envSwap.from}; other projects were left unchanged.` : "Doctor overrides options for all projects at once; apply the change per project if they need different settings.";
|
|
392
|
-
log(
|
|
391
|
+
log($.dim(` ${note}`));
|
|
393
392
|
}
|
|
394
|
-
log(
|
|
393
|
+
log($.dim(" Trade-offs of every option: https://vitest.dev/guide/improving-performance"));
|
|
395
394
|
}
|
|
396
395
|
/**
|
|
397
396
|
* The measured runs execute this script instead of the CLI binary: it accepts
|
|
@@ -425,15 +424,15 @@ process.exit(process.exitCode || 0)
|
|
|
425
424
|
}
|
|
426
425
|
function logFailureExcerpt(title, stderr) {
|
|
427
426
|
log();
|
|
428
|
-
log(` ${
|
|
427
|
+
log(` ${$.red(title)}`);
|
|
429
428
|
if (!stderr.trim()) {
|
|
430
|
-
log(
|
|
429
|
+
log($.dim(" (the run produced no error output - rerun with the same options to inspect it)"));
|
|
431
430
|
return;
|
|
432
431
|
}
|
|
433
432
|
const lines = stderr.trim().split("\n");
|
|
434
433
|
const excerpt = lines.slice(-15);
|
|
435
|
-
if (lines.length > excerpt.length) log(
|
|
436
|
-
for (const line of excerpt) log(
|
|
434
|
+
if (lines.length > excerpt.length) log($.dim(` … (last ${excerpt.length} lines)`));
|
|
435
|
+
for (const line of excerpt) log($.dim(` ${line}`));
|
|
437
436
|
}
|
|
438
437
|
function candidateNotes(result) {
|
|
439
438
|
switch (result.candidate.id) {
|
|
@@ -459,8 +458,8 @@ function formatSeconds(time) {
|
|
|
459
458
|
}
|
|
460
459
|
function formatDelta(wall, baseline) {
|
|
461
460
|
const delta = Math.round((wall - baseline) / baseline * 100);
|
|
462
|
-
if (delta === 0) return
|
|
463
|
-
return delta < 0 ?
|
|
461
|
+
if (delta === 0) return $.dim("(±0%)");
|
|
462
|
+
return delta < 0 ? $.green(`(${delta}%)`) : $.yellow(`(+${delta}%)`);
|
|
464
463
|
}
|
|
465
464
|
|
|
466
465
|
export { doctor, resolveDoctorCandidates };
|
|
@@ -6,4 +6,4 @@ const isWindows = (isNode || isDeno) && process.platform === "win32";
|
|
|
6
6
|
const isTTY = (isNode || isDeno) && process.stdout?.isTTY && !isCI;
|
|
7
7
|
const isForceColor = () => "FORCE_COLOR" in process.env;
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { isTTY as a, isWindows as b, isForceColor as i };
|