vitest 5.0.3 → 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 +1 -1
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +11 -11
- package/dist/chunks/{base.DhkQeZwd.js → base.CYbb9pQW.js} +39 -15
- package/dist/chunks/{browser.d.3cffPS1V.d.ts → browser.d.FGQ9_rK6.d.ts} +3 -3
- package/dist/chunks/{cac.DfDGTQ9W.js → cac.DTXWs6Ni.js} +21 -23
- package/dist/chunks/cli-api.Bx28WXzL.js +13879 -0
- package/dist/chunks/{config.d.BxjInJat.d.ts → config.d.QBNYCgFU.d.ts} +20 -9
- package/dist/chunks/{console.RBA5x-0t.js → console.DtI4yxfN.js} +5 -5
- package/dist/chunks/{coverage.S6Dao4g-.js → coverage.-bm5IxnW.js} +1 -1
- package/dist/chunks/{coverage._yXj5zeb.js → coverage.cTDc4uSS.js} +1 -1
- package/dist/chunks/{creator.203NYCo3.js → creator.CLL8QFMS.js} +43 -53
- package/dist/chunks/{defaults.D2ip7f-X.js → defaults.B1FCaFfh.js} +2 -2
- package/dist/chunks/{display.CXBnkt9a.js → display.BlTmubjj.js} +1 -1
- package/dist/chunks/{doctor.CpHPRoza.js → doctor.Bqc8NDDb.js} +40 -41
- package/dist/chunks/{env.DzFJjrmK.js → env.BKKtU2WC.js} +1 -1
- package/dist/chunks/{environment.d.DAj1Vt__.d.ts → environment.d.BY56MoGs.d.ts} +1 -1
- package/dist/chunks/{globals.9QtHn8Sr.js → globals.CTWMSIPL.js} +10 -10
- package/dist/chunks/{index.DpLw24bj.js → index.B8VfM7Mf.js} +6233 -18539
- package/dist/chunks/{index.DXQx-kDM.js → index.BoyTG_B7.js} +9 -4
- package/dist/chunks/{index.k8L_ZRzq.js → index.CPNMO3h-.js} +54 -46
- package/dist/chunks/{index.cx-_w29y.js → index.D0heQG4v.js} +5 -3
- package/dist/chunks/{index.ggMXe2IF.js → index.GYMZ12wH.js} +5 -5
- package/dist/chunks/{index.C4tKZ0yW.js → index.uwTEEBsB.js} +88 -68
- package/dist/chunks/{init-forks.hzLs7kMZ.js → init-forks.CbYYa5xq.js} +1 -1
- package/dist/chunks/{init-threads.COb0VD5D.js → init-threads.DtjdvxPl.js} +1 -1
- package/dist/chunks/{init.D0qF-GGk.js → init.DrHtV5zd.js} +7 -6
- package/dist/chunks/module-dependencies.CwNPkcV4.js +71 -0
- package/dist/chunks/{native.CBlba4VV.js → native.cdzHIdmv.js} +47 -33
- package/dist/chunks/{nativeModuleMocker.CXSh3m91.js → nativeModuleMocker.D8f4cW4A.js} +2 -2
- package/dist/chunks/{nativeModuleRunner.jwZPY3dg.js → nativeModuleRunner.xi64Afb2.js} +1 -1
- package/dist/chunks/{node.BzimPqT5.js → node.uQulW0ei.js} +1 -1
- package/dist/chunks/{pathe.M-eThtNZ.CknpM8Or.js → pathe.M-eThtNZ.Ba-7h1rE.js} +8 -6
- package/dist/chunks/{plugin.d.BsjqSb4-.d.ts → plugin.d.C8mmycim.d.ts} +88 -53
- package/dist/chunks/{plugins.D2ut1V9b.js → plugins.DPQHVT0p.js} +1 -1
- package/dist/chunks/{resolver.fbW9AUvG.js → resolver.CtCcxIy1.js} +1 -1
- package/dist/chunks/{rpc.BTmCtPly.js → rpc.DpkUyY1N.js} +2 -2
- package/dist/chunks/{rpc.d.BPFHl-HE.d.ts → rpc.d.Cft1biqy.d.ts} +2 -1
- package/dist/chunks/{run.BTlFXlnv.js → run.Cm2sd7-x.js} +97 -82
- package/dist/chunks/{setup-common.BglbuAHD.js → setup-common.BABL3z3m.js} +3 -3
- package/dist/chunks/{source-map.DUxvo12T.js → source-map.DdKI5IHB.js} +13 -4
- package/dist/chunks/{source-map.d.BLHtC2OB.d.ts → source-map.d.kzFtk_dj.d.ts} +1 -1
- package/dist/chunks/{spy.DgMTfhrK.js → spy.DDMXghXv.js} +45 -16
- package/dist/chunks/{task-utils.d.C-IeGxLU.d.ts → task-utils.d.PFh2BV6Q.d.ts} +1 -1
- package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
- package/dist/chunks/{utils.RcGwuOc_.js → utils.DSfl_w8V.js} +44 -42
- package/dist/chunks/{vm.vTyZj_02.js → vm.Uo_C9Uld.js} +14 -11
- package/dist/chunks/{worker.d.Bt2A2mmi.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 +2 -2
- package/dist/node.d.ts +9 -10
- package/dist/node.js +26 -25
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +4 -4
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +6 -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/package.json +28 -27
- package/dist/chunks/cli-api.C4x4GGip.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
|
|
@@ -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
|
|
@@ -3750,6 +3760,7 @@ interface SerializedConfig {
|
|
|
3750
3760
|
};
|
|
3751
3761
|
viteModuleRunner: boolean;
|
|
3752
3762
|
nodeLoader: boolean;
|
|
3763
|
+
recordDependencies: boolean;
|
|
3753
3764
|
openTelemetry: {
|
|
3754
3765
|
enabled: boolean;
|
|
3755
3766
|
sdkPath?: string;
|
|
@@ -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.
|
|
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 './index.
|
|
8
|
-
import './pathe.M-eThtNZ.
|
|
7
|
+
import './index.D0heQG4v.js';
|
|
8
|
+
import './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
9
9
|
|
|
10
10
|
const RealDate = globalThis.Date;
|
|
11
11
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
@@ -142,7 +142,7 @@ function createCustomConsole(defaultState) {
|
|
|
142
142
|
return new Console({
|
|
143
143
|
stdout,
|
|
144
144
|
stderr,
|
|
145
|
-
colorMode:
|
|
145
|
+
colorMode: $.isColorSupported,
|
|
146
146
|
groupIndentation: 2
|
|
147
147
|
});
|
|
148
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.CknpM8Or.js';
|
|
11
|
-
import './source-map.DUxvo12T.js';
|
|
12
|
-
import './index.cx-_w29y.js';
|
|
13
|
-
import './cac.DfDGTQ9W.js';
|
|
14
|
-
import 'events';
|
|
15
|
-
import './env.DzFJjrmK.js';
|
|
16
|
-
import 'std-env';
|
|
17
|
-
import './constants.-juJ8b_4.js';
|
|
18
|
-
import 'node:assert';
|
|
19
|
-
import 'node:perf_hooks';
|
|
20
|
-
import './index.DmDMHCg8.js';
|
|
21
|
-
import 'https';
|
|
22
|
-
import 'http';
|
|
23
|
-
import 'net';
|
|
24
|
-
import 'tls';
|
|
25
|
-
import 'crypto';
|
|
26
|
-
import 'stream';
|
|
27
|
-
import 'url';
|
|
28
|
-
import 'zlib';
|
|
29
|
-
import 'buffer';
|
|
30
|
-
import 'util';
|
|
31
|
-
import 'vite';
|
|
32
|
-
import 'node:crypto';
|
|
33
|
-
import '../path.js';
|
|
34
9
|
import 'node:url';
|
|
35
|
-
import './
|
|
36
|
-
import './
|
|
37
|
-
import '../task-utils.js';
|
|
38
|
-
import './nativeModuleRunner.jwZPY3dg.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.fbW9AUvG.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 = {
|
|
@@ -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 };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { g as globalApis } from './constants.-juJ8b_4.js';
|
|
2
|
-
import { i as index } from './index.
|
|
3
|
-
import './run.
|
|
4
|
-
import './index.
|
|
5
|
-
import './tinyrainbow.
|
|
6
|
-
import './display.
|
|
7
|
-
import './pathe.M-eThtNZ.
|
|
8
|
-
import './source-map.
|
|
2
|
+
import { i as index } from './index.uwTEEBsB.js';
|
|
3
|
+
import './run.Cm2sd7-x.js';
|
|
4
|
+
import './index.D0heQG4v.js';
|
|
5
|
+
import './tinyrainbow.Do8I1XRG.js';
|
|
6
|
+
import './display.BlTmubjj.js';
|
|
7
|
+
import './pathe.M-eThtNZ.Ba-7h1rE.js';
|
|
8
|
+
import './source-map.DdKI5IHB.js';
|
|
9
9
|
import '../task-utils.js';
|
|
10
10
|
import './utils.DYj33du9.js';
|
|
11
|
-
import './spy.
|
|
11
|
+
import './spy.DDMXghXv.js';
|
|
12
12
|
import 'chai';
|
|
13
|
-
import './plugins.
|
|
13
|
+
import './plugins.DPQHVT0p.js';
|
|
14
14
|
import './offset.Dy-5Fdfn.js';
|
|
15
|
-
import './rpc.
|
|
15
|
+
import './rpc.DpkUyY1N.js';
|
|
16
16
|
import 'vite/module-runner';
|
|
17
17
|
import './index.DmDMHCg8.js';
|
|
18
18
|
import 'tinybench';
|