vitest 5.0.0-beta.5 → 5.0.0-beta.7
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 +165 -1
- package/dist/browser.d.ts +27 -14
- package/dist/browser.js +11 -14
- package/dist/chunks/{artifact.C0OHWdod.js → artifact.DC5WoEgy.js} +1310 -13
- package/dist/chunks/{base.BPbmtl-C.js → base.B0fUxpj9.js} +17 -13
- package/dist/chunks/{browser.d.B-p-y0sB.d.ts → browser.d.BFOby8YL.d.ts} +3 -3
- package/dist/chunks/{cac.DYQRhgb-.js → cac.B41kXwyU.js} +22 -24
- package/dist/chunks/check.Cz_-YojU.js +15 -0
- package/dist/chunks/cli-api.bqNN5viV.js +519 -0
- package/dist/chunks/{config.d.Bkl6J5iR.d.ts → config.d.DsC1jkby.d.ts} +877 -27
- package/dist/chunks/{console.DjVIMaXT.js → console.omGxyKMT.js} +5 -5
- package/dist/chunks/{coverage.CTzCuANN.js → coverage.BVb1JqW7.js} +7 -2
- package/dist/chunks/coverage.BfSEMtie.js +26 -0
- package/dist/chunks/coverage.d.ByaAMV4A.d.ts +88 -0
- package/dist/chunks/{creator.CJiHagNv.js → creator.BzMFaPC-.js} +54 -30
- package/dist/chunks/{defaults.CUUnbOrq.js → defaults.BJUmAuaO.js} +3 -2
- package/dist/chunks/display.CYwyMF4S.js +192 -0
- package/dist/chunks/{env.BKKtU2WC.js → env.DzFJjrmK.js} +1 -1
- package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.4-rzQgpt.d.ts} +1 -1
- package/dist/chunks/globals.sd6Qutmc.js +28 -0
- package/dist/chunks/{cli-api.SMst4llK.js → index.5krd73UD.js} +14591 -13056
- package/dist/chunks/{index.CXzZ7KB8.js → index.CLtI1k_4.js} +627 -214
- package/dist/chunks/{index.DzNNaFWy.js → index.DxR-nMjO.js} +63 -10
- package/dist/chunks/index.DzTmMrSM.js +940 -0
- package/dist/chunks/{index.DugGyGng.js → index.JaztIWgW.js} +6 -5
- package/dist/chunks/{init-forks.CDWjf0q6.js → init-forks.CXzT841o.js} +1 -1
- package/dist/chunks/{init-threads.B-vZ8N2q.js → init-threads.Ch-Bw5j3.js} +1 -1
- package/dist/chunks/{init.gslB1aqB.js → init.CfiYZpFg.js} +41 -25
- package/dist/chunks/{native.DPzPHdi5.js → native.BUCvPRKp.js} +3 -4
- package/dist/chunks/{nativeModuleMocker.CrcWvO03.js → nativeModuleMocker.Uot80PXb.js} +2 -3
- package/dist/chunks/{index.CesbTg1C.js → nativeModuleRunner.BDnwGb8g.js} +39 -3
- package/dist/chunks/{node.C9I1sbE9.js → node.BPMnm_Q2.js} +1 -1
- package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
- package/dist/chunks/pathe.M-eThtNZ.CbK_Vbae.js +489 -0
- package/dist/chunks/{plugin.d.BuiCQSo8.d.ts → plugin.d.BOjbmxWW.d.ts} +1757 -1566
- package/dist/chunks/{plugins.DrsmdUE2.js → plugins.CsoX-42X.js} +1 -1
- package/dist/chunks/resolver.CERfsKE-.js +48 -0
- package/dist/chunks/{rpc.d.BLxNuPAq.d.ts → rpc.d.BeasqWpO.d.ts} +14 -1
- package/dist/chunks/{rpc.DZEh5xnQ.js → rpc.iNjF664v.js} +2 -2
- package/dist/chunks/setup-common.vxjAyUtK.js +36 -0
- package/dist/chunks/setup.DasACXvo.js +5409 -0
- package/dist/chunks/source-map.DZdIqpIJ.js +1776 -0
- package/dist/chunks/spy.B8mHA9qu.js +422 -0
- package/dist/chunks/{task-utils.d.CLWcZaUf.d.ts → task-utils.d.BKHiHxSN.d.ts} +20 -2
- package/dist/chunks/tinyrainbow.Ht9iggcq.js +95 -0
- package/dist/chunks/{utils.DKODp04v.js → utils.CO-iLyCr.js} +41 -42
- package/dist/chunks/{vm._FqKqltU.js → vm.DoQh8CN9.js} +110 -11
- package/dist/chunks/{worker.d.Cb0Z-SnE.d.ts → worker.d.s_RdeZtI.d.ts} +14 -11
- package/dist/cli.js +4 -5
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +19 -17
- package/dist/config.js +2 -2
- package/dist/index.d.ts +241 -31
- package/dist/index.js +11 -16
- package/dist/module-evaluator.d.ts +40 -8
- package/dist/module-evaluator.js +73 -22
- package/dist/node.d.ts +225 -86
- package/dist/node.js +30 -66
- package/dist/runtime.d.ts +6 -11
- package/dist/runtime.js +4 -5
- package/dist/spy.js +1 -1
- package/dist/task-utils.js +1 -2
- package/dist/worker.d.ts +5 -10
- package/dist/worker.js +24 -36
- package/dist/workers/forks.js +21 -33
- package/dist/workers/runVmTests.js +15 -20
- package/dist/workers/threads.js +21 -33
- package/dist/workers/vmForks.js +13 -15
- package/dist/workers/vmThreads.js +13 -15
- package/package.json +20 -20
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
- package/dist/chunks/coverage.d.Dn6XbyQq.d.ts +0 -43
- package/dist/chunks/globals.D2wDMk06.js +0 -33
- package/dist/chunks/index.6dZyLbho.js +0 -6918
- package/dist/chunks/nativeModuleRunner.WlMdOB52.js +0 -36
- package/dist/chunks/setup-common.DRlwpHsL.js +0 -64
|
@@ -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 { getSafeTimers } from '
|
|
5
|
-
import
|
|
6
|
-
import { R as RealDate } from './rpc.
|
|
4
|
+
import { a as getSafeTimers } from './source-map.DZdIqpIJ.js';
|
|
5
|
+
import { y } from './tinyrainbow.Ht9iggcq.js';
|
|
6
|
+
import { R as RealDate } from './rpc.iNjF664v.js';
|
|
7
7
|
import { g as getWorkerState } from './utils.DYj33du9.js';
|
|
8
|
-
import 'pathe';
|
|
8
|
+
import './pathe.M-eThtNZ.CbK_Vbae.js';
|
|
9
9
|
import 'vite/module-runner';
|
|
10
10
|
import './index.Chj8NDwU.js';
|
|
11
11
|
|
|
@@ -141,7 +141,7 @@ function createCustomConsole(defaultState) {
|
|
|
141
141
|
schedule(id);
|
|
142
142
|
callback();
|
|
143
143
|
} }),
|
|
144
|
-
colorMode:
|
|
144
|
+
colorMode: y.isColorSupported,
|
|
145
145
|
groupIndentation: 2
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { r as resolve } from './pathe.M-eThtNZ.CbK_Vbae.js';
|
|
2
|
+
|
|
3
|
+
function getCoverageFilesDirectory(reportsDirectory, shard) {
|
|
4
|
+
return resolve(reportsDirectory, `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`);
|
|
5
|
+
}
|
|
1
6
|
const CoverageProviderMap = {
|
|
2
7
|
v8: "@vitest/coverage-v8",
|
|
3
8
|
istanbul: "@vitest/coverage-istanbul"
|
|
@@ -7,7 +12,7 @@ async function resolveCoverageProviderModule(options, loader) {
|
|
|
7
12
|
const provider = options.provider;
|
|
8
13
|
if (provider === "v8" || provider === "istanbul") {
|
|
9
14
|
let builtInModule = CoverageProviderMap[provider];
|
|
10
|
-
if (
|
|
15
|
+
if (loader.isBrowser) builtInModule += "/browser";
|
|
11
16
|
const { default: coverageModule } = loader.isBrowser ? await loader.import(builtInModule) : await import(
|
|
12
17
|
/* @vite-ignore */
|
|
13
18
|
builtInModule
|
|
@@ -25,4 +30,4 @@ async function resolveCoverageProviderModule(options, loader) {
|
|
|
25
30
|
return customProviderModule.default;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
export { CoverageProviderMap as C, resolveCoverageProviderModule as r };
|
|
33
|
+
export { CoverageProviderMap as C, getCoverageFilesDirectory as g, resolveCoverageProviderModule as r };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { r as resolveCoverageProviderModule } from './coverage.BVb1JqW7.js';
|
|
2
|
+
|
|
3
|
+
async function startCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
4
|
+
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
5
|
+
if (coverageModule) return coverageModule.startCoverage?.({
|
|
6
|
+
...runtimeOptions,
|
|
7
|
+
autoAttachSubprocess: options.autoAttachSubprocess,
|
|
8
|
+
reportsDirectory: options.reportsDirectory
|
|
9
|
+
});
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
async function takeCoverageInsideWorker(options, loader) {
|
|
13
|
+
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
14
|
+
if (coverageModule) return coverageModule.takeCoverage?.({
|
|
15
|
+
moduleExecutionInfo: loader.moduleExecutionInfo,
|
|
16
|
+
coverageFilesDirectory: options.coverageFilesDirectory
|
|
17
|
+
});
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
|
|
21
|
+
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
22
|
+
if (coverageModule) return coverageModule.stopCoverage?.(runtimeOptions);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { stopCoverageInsideWorker as a, startCoverageInsideWorker as s, takeCoverageInsideWorker as t };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { aU as TestError, au as ParsedStack } from './config.d.DsC1jkby.js';
|
|
2
|
+
|
|
3
|
+
type OriginalMapping = {
|
|
4
|
+
source: string | null;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
name: string | null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface StackTraceParserOptions {
|
|
11
|
+
ignoreStackEntries?: (RegExp | string)[];
|
|
12
|
+
getSourceMap?: (file: string) => unknown;
|
|
13
|
+
getUrlId?: (id: string) => string;
|
|
14
|
+
frameFilter?: (error: TestError, frame: ParsedStack) => boolean | void;
|
|
15
|
+
}
|
|
16
|
+
interface SourceMapLike {
|
|
17
|
+
version: number;
|
|
18
|
+
mappings?: string;
|
|
19
|
+
names?: string[];
|
|
20
|
+
sources?: string[];
|
|
21
|
+
sourcesContent?: string[];
|
|
22
|
+
sourceRoot?: string;
|
|
23
|
+
}
|
|
24
|
+
interface Needle {
|
|
25
|
+
line: number;
|
|
26
|
+
column: number;
|
|
27
|
+
}
|
|
28
|
+
declare class DecodedMap {
|
|
29
|
+
map: SourceMapLike;
|
|
30
|
+
_encoded: string;
|
|
31
|
+
_decoded: undefined | number[][][];
|
|
32
|
+
_decodedMemo: Stats;
|
|
33
|
+
url: string;
|
|
34
|
+
version: number;
|
|
35
|
+
names: string[];
|
|
36
|
+
resolvedSources: string[];
|
|
37
|
+
constructor(map: SourceMapLike, from: string);
|
|
38
|
+
}
|
|
39
|
+
interface Stats {
|
|
40
|
+
lastKey: number;
|
|
41
|
+
lastNeedle: number;
|
|
42
|
+
lastIndex: number;
|
|
43
|
+
}
|
|
44
|
+
declare function getOriginalPosition(map: DecodedMap, needle: Needle): OriginalMapping | null;
|
|
45
|
+
|
|
46
|
+
interface RuntimeCoverageModuleLoader {
|
|
47
|
+
import: (id: string) => Promise<{
|
|
48
|
+
default: RuntimeCoverageProviderModule;
|
|
49
|
+
}>;
|
|
50
|
+
isBrowser?: boolean;
|
|
51
|
+
moduleExecutionInfo?: Map<string, {
|
|
52
|
+
startOffset: number;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
interface RuntimeCoverageProviderModule {
|
|
56
|
+
/**
|
|
57
|
+
* Factory for creating a new coverage provider
|
|
58
|
+
*/
|
|
59
|
+
getProvider: () => any;
|
|
60
|
+
/**
|
|
61
|
+
* Executed before tests are run in the worker thread.
|
|
62
|
+
*/
|
|
63
|
+
startCoverage?: (runtimeOptions: {
|
|
64
|
+
isolate: boolean;
|
|
65
|
+
/** @internal */
|
|
66
|
+
autoAttachSubprocess: boolean;
|
|
67
|
+
/** @internal */
|
|
68
|
+
reportsDirectory: string;
|
|
69
|
+
}) => unknown | Promise<unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* Executed on after each run in the worker thread. Possible to return a payload passed to the provider
|
|
72
|
+
*/
|
|
73
|
+
takeCoverage?: (runtimeOptions?: {
|
|
74
|
+
moduleExecutionInfo?: Map<string, {
|
|
75
|
+
startOffset: number;
|
|
76
|
+
}>;
|
|
77
|
+
coverageFilesDirectory: string;
|
|
78
|
+
}) => unknown | Promise<unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Executed after all tests have been run in the worker thread.
|
|
81
|
+
*/
|
|
82
|
+
stopCoverage?: (runtimeOptions: {
|
|
83
|
+
isolate: boolean;
|
|
84
|
+
}) => unknown | Promise<unknown>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { DecodedMap as D, getOriginalPosition as g };
|
|
88
|
+
export type { RuntimeCoverageModuleLoader as R, StackTraceParserOptions as S, RuntimeCoverageProviderModule as a };
|
|
@@ -2,31 +2,55 @@ 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.CMESou6r.js';
|
|
5
|
-
import {
|
|
5
|
+
import { w as prompt, x as findConfigFile } from './index.5krd73UD.js';
|
|
6
6
|
import { x } from 'tinyexec';
|
|
7
|
-
import
|
|
7
|
+
import { y } from './tinyrainbow.Ht9iggcq.js';
|
|
8
8
|
import 'node:process';
|
|
9
|
-
import 'node:
|
|
9
|
+
import 'node:os';
|
|
10
|
+
import './pathe.M-eThtNZ.CbK_Vbae.js';
|
|
11
|
+
import './source-map.DZdIqpIJ.js';
|
|
12
|
+
import './cac.B41kXwyU.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 '../path.js';
|
|
10
19
|
import 'node:url';
|
|
11
|
-
import '
|
|
12
|
-
import './index.
|
|
20
|
+
import './artifact.DC5WoEgy.js';
|
|
21
|
+
import './index.DzTmMrSM.js';
|
|
22
|
+
import './display.CYwyMF4S.js';
|
|
23
|
+
import '../task-utils.js';
|
|
24
|
+
import './nativeModuleRunner.BDnwGb8g.js';
|
|
13
25
|
import 'node:module';
|
|
14
|
-
import 'pathe';
|
|
15
|
-
import 'node:assert';
|
|
16
26
|
import 'node:v8';
|
|
17
27
|
import 'node:util';
|
|
18
|
-
import '
|
|
28
|
+
import 'vite/module-runner';
|
|
29
|
+
import '../traces.js';
|
|
19
30
|
import 'vite';
|
|
20
|
-
import '
|
|
21
|
-
import '
|
|
22
|
-
import '
|
|
23
|
-
import './
|
|
24
|
-
import '
|
|
25
|
-
import '
|
|
26
|
-
import '
|
|
27
|
-
import '
|
|
31
|
+
import 'obug';
|
|
32
|
+
import 'node:crypto';
|
|
33
|
+
import 'tinyglobby';
|
|
34
|
+
import './defaults.BJUmAuaO.js';
|
|
35
|
+
import 'magic-string';
|
|
36
|
+
import '@vitest/mocker/node';
|
|
37
|
+
import 'node:console';
|
|
38
|
+
import 'node:stream';
|
|
39
|
+
import 'node:perf_hooks';
|
|
40
|
+
import './offset.Dy-5Fdfn.js';
|
|
41
|
+
import './utils.CO-iLyCr.js';
|
|
42
|
+
import '#module-evaluator';
|
|
43
|
+
import 'picomatch';
|
|
44
|
+
import './coverage.BVb1JqW7.js';
|
|
45
|
+
import './resolver.CERfsKE-.js';
|
|
46
|
+
import 'es-module-lexer';
|
|
47
|
+
import 'node:tty';
|
|
48
|
+
import 'node:events';
|
|
49
|
+
import './index.Chj8NDwU.js';
|
|
50
|
+
import './modules.BJuCwlRJ.js';
|
|
51
|
+
import 'node:child_process';
|
|
52
|
+
import 'node:worker_threads';
|
|
28
53
|
import 'readline';
|
|
29
|
-
import 'events';
|
|
30
54
|
|
|
31
55
|
const jsxExample = {
|
|
32
56
|
name: "HelloWorld.jsx",
|
|
@@ -475,11 +499,11 @@ function getLanguageOptions() {
|
|
|
475
499
|
}
|
|
476
500
|
async function installPackages(pkgManager, packages) {
|
|
477
501
|
if (!packages.length) {
|
|
478
|
-
log(
|
|
502
|
+
log(y.green("✔"), y.bold("All packages are already installed."));
|
|
479
503
|
return;
|
|
480
504
|
}
|
|
481
|
-
log(
|
|
482
|
-
log(
|
|
505
|
+
log(y.cyan("◼"), y.bold("Installing packages..."));
|
|
506
|
+
log(y.cyan("◼"), packages.join(", "));
|
|
483
507
|
log();
|
|
484
508
|
await installPackage(packages, {
|
|
485
509
|
dev: true,
|
|
@@ -579,7 +603,7 @@ async function updatePkgJsonScripts(pkgJsonPath, vitestScript) {
|
|
|
579
603
|
pkg.scripts["test:browser"] = vitestScript;
|
|
580
604
|
await writeFile(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf-8");
|
|
581
605
|
}
|
|
582
|
-
log(
|
|
606
|
+
log(y.green("✔"), "Added \"test:browser\" script to your package.json.");
|
|
583
607
|
}
|
|
584
608
|
function getRunScript(pkgManager) {
|
|
585
609
|
switch (pkgManager) {
|
|
@@ -602,7 +626,7 @@ function getPlaywrightRunArgs(pkgManager) {
|
|
|
602
626
|
}
|
|
603
627
|
}
|
|
604
628
|
async function create() {
|
|
605
|
-
log(
|
|
629
|
+
log(y.cyan("◼"), "This utility will help you set up a browser testing environment.\n");
|
|
606
630
|
const pkgJsonPath = resolve(process.cwd(), "package.json");
|
|
607
631
|
const pkg = readPkgJson(pkgJsonPath) || {};
|
|
608
632
|
const dependencies = {
|
|
@@ -670,13 +694,13 @@ async function create() {
|
|
|
670
694
|
browsers
|
|
671
695
|
});
|
|
672
696
|
log(
|
|
673
|
-
|
|
697
|
+
y.green("✔"),
|
|
674
698
|
"Created a new config file for browser tests:",
|
|
675
|
-
|
|
699
|
+
y.bold(relative(process.cwd(), configPath)),
|
|
676
700
|
// TODO: Can we modify the config ourselves?
|
|
677
701
|
"\nSince you already have a Vitest config file, it is recommended to copy the contents of the new file ",
|
|
678
702
|
"into your existing config located at ",
|
|
679
|
-
|
|
703
|
+
y.bold(relative(process.cwd(), rootConfig))
|
|
680
704
|
);
|
|
681
705
|
} else {
|
|
682
706
|
const configPath = resolve(process.cwd(), `vitest.config.${lang}`);
|
|
@@ -687,7 +711,7 @@ async function create() {
|
|
|
687
711
|
provider,
|
|
688
712
|
browsers
|
|
689
713
|
});
|
|
690
|
-
log(
|
|
714
|
+
log(y.green("✔"), "Created a config file for browser tests:", y.bold(relative(process.cwd(), configPath)));
|
|
691
715
|
}
|
|
692
716
|
log();
|
|
693
717
|
await updatePkgJsonScripts(pkgJsonPath, scriptCommand);
|
|
@@ -700,7 +724,7 @@ async function create() {
|
|
|
700
724
|
"install",
|
|
701
725
|
"--with-deps"
|
|
702
726
|
];
|
|
703
|
-
log(
|
|
727
|
+
log(y.cyan("◼"), `Installing Playwright dependencies with \`${y.bold(command)} ${y.bold(allArgs.join(" "))}\`...`);
|
|
704
728
|
log();
|
|
705
729
|
await x(command, allArgs, { nodeOptions: { stdio: [
|
|
706
730
|
"pipe",
|
|
@@ -710,10 +734,10 @@ async function create() {
|
|
|
710
734
|
}
|
|
711
735
|
log();
|
|
712
736
|
const exampleTestFile = await generateExampleFiles(framework, lang);
|
|
713
|
-
log(
|
|
714
|
-
log(
|
|
737
|
+
log(y.green("✔"), "Created example test file in", y.bold(relative(process.cwd(), exampleTestFile)));
|
|
738
|
+
log(y.dim(" You can safely delete this file once you have written your own tests."));
|
|
715
739
|
log();
|
|
716
|
-
log(
|
|
740
|
+
log(y.cyan("◼"), "All done! Run your tests with", y.bold(getRunScript(pkgManager)));
|
|
717
741
|
}
|
|
718
742
|
|
|
719
743
|
export { create };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import nodeos__default from 'node:os';
|
|
2
|
-
import './env.
|
|
2
|
+
import './env.DzFJjrmK.js';
|
|
3
3
|
import { isCI, isAgent } from 'std-env';
|
|
4
4
|
|
|
5
5
|
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
@@ -50,8 +50,9 @@ const configDefaults = Object.freeze({
|
|
|
50
50
|
isolate: true,
|
|
51
51
|
watch: !isCI && process.stdin.isTTY && !isAgent,
|
|
52
52
|
globals: false,
|
|
53
|
+
injectCjsGlobals: true,
|
|
53
54
|
environment: "node",
|
|
54
|
-
clearMocks:
|
|
55
|
+
clearMocks: true,
|
|
55
56
|
restoreMocks: false,
|
|
56
57
|
mockReset: false,
|
|
57
58
|
unstubGlobals: false,
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { f as format$1, p as plugins, c as createDOMElementFilter } from './index.DzTmMrSM.js';
|
|
2
|
+
|
|
3
|
+
const { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
|
|
4
|
+
const PLUGINS = [
|
|
5
|
+
ReactTestComponent,
|
|
6
|
+
ReactElement,
|
|
7
|
+
DOMElement,
|
|
8
|
+
DOMCollection,
|
|
9
|
+
Immutable,
|
|
10
|
+
AsymmetricMatcher
|
|
11
|
+
];
|
|
12
|
+
function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
|
|
13
|
+
const MAX_LENGTH = maxLength ?? 1e4;
|
|
14
|
+
let result;
|
|
15
|
+
// Convert string selector to filter function
|
|
16
|
+
const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
|
|
17
|
+
const plugins = filterFn ? [
|
|
18
|
+
ReactTestComponent,
|
|
19
|
+
ReactElement,
|
|
20
|
+
createDOMElementFilter(filterFn),
|
|
21
|
+
DOMCollection,
|
|
22
|
+
Immutable,
|
|
23
|
+
AsymmetricMatcher
|
|
24
|
+
] : PLUGINS;
|
|
25
|
+
try {
|
|
26
|
+
result = format$1(object, {
|
|
27
|
+
maxDepth,
|
|
28
|
+
escapeString: false,
|
|
29
|
+
plugins,
|
|
30
|
+
...options
|
|
31
|
+
});
|
|
32
|
+
} catch {
|
|
33
|
+
result = format$1(object, {
|
|
34
|
+
callToJSON: false,
|
|
35
|
+
maxDepth,
|
|
36
|
+
escapeString: false,
|
|
37
|
+
plugins,
|
|
38
|
+
...options
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// Prevents infinite loop https://github.com/vitest-dev/vitest/issues/7249
|
|
42
|
+
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
|
|
43
|
+
maxLength,
|
|
44
|
+
filterNode,
|
|
45
|
+
...options
|
|
46
|
+
}) : result;
|
|
47
|
+
}
|
|
48
|
+
function createNodeFilterFromSelector(selector) {
|
|
49
|
+
const ELEMENT_NODE = 1;
|
|
50
|
+
const COMMENT_NODE = 8;
|
|
51
|
+
return (node) => {
|
|
52
|
+
// Filter out comments
|
|
53
|
+
if (node.nodeType === COMMENT_NODE) return false;
|
|
54
|
+
// Filter out elements matching the selector
|
|
55
|
+
if (node.nodeType === ELEMENT_NODE && node.matches) try {
|
|
56
|
+
return !node.matches(selector);
|
|
57
|
+
} catch {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const formatRegExp = /%[sdjifoOc%]/g;
|
|
64
|
+
function format(args, options = {}) {
|
|
65
|
+
const formatArg = (item) => inspect(item, options);
|
|
66
|
+
if (typeof args[0] !== "string") {
|
|
67
|
+
const objects = [];
|
|
68
|
+
for (let i = 0; i < args.length; i++) objects.push(formatArg(args[i]));
|
|
69
|
+
return objects.join(" ");
|
|
70
|
+
}
|
|
71
|
+
const len = args.length;
|
|
72
|
+
let i = 1;
|
|
73
|
+
const template = args[0];
|
|
74
|
+
let str = String(template).replace(formatRegExp, (x) => {
|
|
75
|
+
if (x === "%%") return "%";
|
|
76
|
+
if (i >= len) return x;
|
|
77
|
+
switch (x) {
|
|
78
|
+
case "%s": {
|
|
79
|
+
const value = args[i++];
|
|
80
|
+
if (typeof value === "bigint") return `${value.toString()}n`;
|
|
81
|
+
if (typeof value === "number" && value === 0 && 1 / value < 0) return "-0";
|
|
82
|
+
if (typeof value === "object" && value !== null) {
|
|
83
|
+
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) return value.toString();
|
|
84
|
+
return formatArg(value);
|
|
85
|
+
}
|
|
86
|
+
return String(value);
|
|
87
|
+
}
|
|
88
|
+
case "%d": {
|
|
89
|
+
const value = args[i++];
|
|
90
|
+
if (typeof value === "bigint") return `${value.toString()}n`;
|
|
91
|
+
if (typeof value === "symbol") return "NaN";
|
|
92
|
+
return Number(value).toString();
|
|
93
|
+
}
|
|
94
|
+
case "%i": {
|
|
95
|
+
const value = args[i++];
|
|
96
|
+
if (typeof value === "bigint") return `${value.toString()}n`;
|
|
97
|
+
return Number.parseInt(String(value)).toString();
|
|
98
|
+
}
|
|
99
|
+
case "%f": return Number.parseFloat(String(args[i++])).toString();
|
|
100
|
+
case "%o":
|
|
101
|
+
case "%O": return formatArg(args[i++]);
|
|
102
|
+
case "%c":
|
|
103
|
+
i++;
|
|
104
|
+
return "";
|
|
105
|
+
case "%j": try {
|
|
106
|
+
return JSON.stringify(args[i++]);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
const m = err.message;
|
|
109
|
+
if (m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")) return "[Circular]";
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
default: return x;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
for (let x = args[i]; i < len; x = args[++i]) if (x === null || typeof x !== "object") str += ` ${typeof x === "symbol" ? x.toString() : x}`;
|
|
116
|
+
else str += ` ${formatArg(x)}`;
|
|
117
|
+
return str;
|
|
118
|
+
}
|
|
119
|
+
function inspect(obj, options) {
|
|
120
|
+
const { truncate, multiline, ...stringifyOptions } = options ?? {};
|
|
121
|
+
const prettyFormatOptions = {
|
|
122
|
+
singleQuote: true,
|
|
123
|
+
quoteKeys: false,
|
|
124
|
+
min: true,
|
|
125
|
+
spacingInner: " ",
|
|
126
|
+
spacingOuter: " ",
|
|
127
|
+
printBasicPrototype: false,
|
|
128
|
+
compareKeys: null,
|
|
129
|
+
...multiline ? {
|
|
130
|
+
min: false,
|
|
131
|
+
spacingInner: void 0,
|
|
132
|
+
spacingOuter: void 0
|
|
133
|
+
} : {}
|
|
134
|
+
};
|
|
135
|
+
const threshold = truncate ?? 0;
|
|
136
|
+
const formatted = stringify(obj, void 0, {
|
|
137
|
+
...prettyFormatOptions,
|
|
138
|
+
...stringifyOptions,
|
|
139
|
+
maxLength: threshold || void 0
|
|
140
|
+
});
|
|
141
|
+
if (threshold === 0 || formatted.length <= threshold) return formatted;
|
|
142
|
+
// if stringify's adaptive maxDepth (down to 1) fails to truncate enough,
|
|
143
|
+
// - for known types (e.g. string, object, array, etc), apply best effort truncation.
|
|
144
|
+
// - for other values, fallback to maxDepth = 0 which should can show minimal output.
|
|
145
|
+
const type = Object.prototype.toString.call(obj);
|
|
146
|
+
if (typeof obj === "string") {
|
|
147
|
+
let end = threshold - 1;
|
|
148
|
+
if (end > 0 && isHighSurrogate(formatted[end - 1])) end = end - 1;
|
|
149
|
+
return `'${formatted.slice(1, end)}…'`;
|
|
150
|
+
}
|
|
151
|
+
if (type === "[object Array]" || type === "[object Object]" || type === "[object Set]" || type === "[object Map]") return stringifyByMaxWidth(obj, threshold, {
|
|
152
|
+
...prettyFormatOptions,
|
|
153
|
+
...stringifyOptions,
|
|
154
|
+
maxDepth: 1
|
|
155
|
+
});
|
|
156
|
+
return stringify(obj, void 0, {
|
|
157
|
+
...prettyFormatOptions,
|
|
158
|
+
...stringifyOptions,
|
|
159
|
+
maxDepth: 0
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function truncateString(string, maxLength) {
|
|
163
|
+
if (string.length <= maxLength) return string;
|
|
164
|
+
let end = maxLength - 1;
|
|
165
|
+
if (isHighSurrogate(string[end - 1])) end = end - 1;
|
|
166
|
+
return `${string.slice(0, end)}…`;
|
|
167
|
+
}
|
|
168
|
+
function stringifyByMaxWidth(object, threshold, options) {
|
|
169
|
+
function evaluate(x) {
|
|
170
|
+
return stringify(object, void 0, {
|
|
171
|
+
...options,
|
|
172
|
+
maxWidth: x
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return evaluate(binarySearch(0, threshold, (x) => evaluate(x).length <= threshold));
|
|
176
|
+
}
|
|
177
|
+
// find max(x \in [x, y) | f(x) = true)
|
|
178
|
+
// if f(x0) is false, then returns x0.
|
|
179
|
+
function binarySearch(x0, x1, f) {
|
|
180
|
+
while (x0 + 1 < x1) {
|
|
181
|
+
const x = Math.floor((x0 + x1) / 2);
|
|
182
|
+
if (f(x)) x0 = x;
|
|
183
|
+
else x1 = x;
|
|
184
|
+
}
|
|
185
|
+
return x0;
|
|
186
|
+
}
|
|
187
|
+
// https://github.com/chaijs/loupe/pull/79
|
|
188
|
+
function isHighSurrogate(char) {
|
|
189
|
+
return char >= "\ud800" && char <= "\udbff";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export { formatRegExp as a, format as f, inspect as i, stringify as s, truncateString as t };
|
|
@@ -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 { isForceColor as a, isTTY as b, isWindows as i };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { g as globalApis } from './constants.-juJ8b_4.js';
|
|
2
|
+
import { i as index } from './index.CLtI1k_4.js';
|
|
3
|
+
import './artifact.DC5WoEgy.js';
|
|
4
|
+
import './index.DzTmMrSM.js';
|
|
5
|
+
import './tinyrainbow.Ht9iggcq.js';
|
|
6
|
+
import './display.CYwyMF4S.js';
|
|
7
|
+
import './pathe.M-eThtNZ.CbK_Vbae.js';
|
|
8
|
+
import './source-map.DZdIqpIJ.js';
|
|
9
|
+
import '../task-utils.js';
|
|
10
|
+
import './utils.DYj33du9.js';
|
|
11
|
+
import './spy.B8mHA9qu.js';
|
|
12
|
+
import './rpc.iNjF664v.js';
|
|
13
|
+
import 'vite/module-runner';
|
|
14
|
+
import './index.Chj8NDwU.js';
|
|
15
|
+
import 'chai';
|
|
16
|
+
import './plugins.CsoX-42X.js';
|
|
17
|
+
import './offset.Dy-5Fdfn.js';
|
|
18
|
+
import 'tinybench';
|
|
19
|
+
import 'expect-type';
|
|
20
|
+
|
|
21
|
+
function registerApiGlobally() {
|
|
22
|
+
globalApis.forEach((api) => {
|
|
23
|
+
// @ts-expect-error I know what I am doing :P
|
|
24
|
+
globalThis[api] = index[api];
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { registerApiGlobally };
|