vitest 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +21 -42
- package/dist/browser.js +5 -5
- package/dist/{vendor/base.Csk7BT3h.js → chunks/base.CC5R_kgU.js} +3 -3
- package/dist/{vendor/base.DRHPZCCj.js → chunks/base.DSsbfkDg.js} +1 -1
- package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
- package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
- package/dist/{vendor/cac.DFtWvZc2.js → chunks/cac.DGgmCKmU.js} +17 -20
- package/dist/{vendor/cli-api.CTkP2Ier.js → chunks/cli-api.OKfd3qJ0.js} +416 -423
- package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
- package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
- package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
- package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
- package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
- package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
- package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
- package/dist/{vendor/execute.jzOWtys_.js → chunks/execute.Cjlr2CRw.js} +27 -19
- package/dist/chunks/globals.BliuJFNR.js +31 -0
- package/dist/{vendor/index.DI9daj1Q.js → chunks/index.BfeNhc0N.js} +43 -43
- package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
- package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
- package/dist/{vendor/index.CuuL9y4g.js → chunks/index.JbiJutJ_.js} +515 -255
- package/dist/{vendor/index.CVqMv71L.js → chunks/index.R1VjssW9.js} +11 -12
- package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
- package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
- package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
- package/dist/{reporters-B7ebVMkT.d.ts → chunks/reporters.C_zwCd4j.d.ts} +847 -1000
- package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
- package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
- package/dist/chunks/{runtime-runBaseTests.Dq_sJZq9.js → runBaseTests.CyvqmuC9.js} +21 -23
- package/dist/{vendor/setup-common.symvFZPh.js → chunks/setup-common.CNzatKMx.js} +2 -2
- package/dist/{suite-CRLAhsm0.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
- package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
- package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
- package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
- package/dist/{vendor/utils.BySfPUwy.js → chunks/utils.DpP_sDwr.js} +8 -21
- package/dist/{vendor/vi.Elqer9-7.js → chunks/vi.fiQ7lMRF.js} +13 -18
- package/dist/{vendor/vm.img-AOox.js → chunks/vm.DcSuuaHr.js} +40 -68
- package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
- package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
- package/dist/cli.js +3 -3
- package/dist/config.cjs +6 -8
- package/dist/config.d.ts +10 -8
- package/dist/config.js +6 -8
- package/dist/coverage.d.ts +10 -8
- package/dist/coverage.js +2 -2
- package/dist/environments.d.ts +3 -19
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +5 -14
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +267 -34
- package/dist/index.js +12 -12
- package/dist/node.d.ts +15 -9
- package/dist/node.js +16 -19
- package/dist/reporters.d.ts +10 -8
- package/dist/reporters.js +12 -15
- package/dist/runners.d.ts +7 -19
- package/dist/runners.js +12 -13
- package/dist/snapshot.js +3 -3
- package/dist/suite.d.ts +2 -16
- package/dist/suite.js +4 -4
- package/dist/worker.js +7 -8
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +18 -19
- package/dist/workers/threads.js +5 -5
- package/dist/workers/vmForks.js +8 -8
- package/dist/workers/vmThreads.js +8 -8
- package/dist/workers.d.ts +13 -8
- package/dist/workers.js +13 -13
- package/package.json +13 -13
- package/dist/chunks/integrations-globals.nDMtdOcn.js +0 -31
- /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
- /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
- /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
- /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
- /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
- /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
- /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { PrettyFormatOptions } from '@vitest/pretty-format';
|
|
2
|
+
import { SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
3
|
+
import { SnapshotUpdateState } from '@vitest/snapshot';
|
|
4
|
+
import { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Names of clock methods that may be faked by install.
|
|
8
|
+
*/
|
|
9
|
+
type FakeMethod =
|
|
10
|
+
| "setTimeout"
|
|
11
|
+
| "clearTimeout"
|
|
12
|
+
| "setImmediate"
|
|
13
|
+
| "clearImmediate"
|
|
14
|
+
| "setInterval"
|
|
15
|
+
| "clearInterval"
|
|
16
|
+
| "Date"
|
|
17
|
+
| "nextTick"
|
|
18
|
+
| "hrtime"
|
|
19
|
+
| "requestAnimationFrame"
|
|
20
|
+
| "cancelAnimationFrame"
|
|
21
|
+
| "requestIdleCallback"
|
|
22
|
+
| "cancelIdleCallback"
|
|
23
|
+
| "performance"
|
|
24
|
+
| "queueMicrotask";
|
|
25
|
+
|
|
26
|
+
interface FakeTimerInstallOpts {
|
|
27
|
+
/**
|
|
28
|
+
* Installs fake timers with the specified unix epoch (default: 0)
|
|
29
|
+
*/
|
|
30
|
+
now?: number | Date | undefined;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An array with names of global methods and APIs to fake.
|
|
34
|
+
* For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()`
|
|
35
|
+
* @default ['setTimeout', 'clearTimeout', 'setImmediate', 'clearImmediate', 'setInterval', 'clearInterval', 'Date']
|
|
36
|
+
*/
|
|
37
|
+
toFake?: FakeMethod[] | undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The maximum number of timers that will be run when calling runAll()
|
|
41
|
+
* @default 10000
|
|
42
|
+
*/
|
|
43
|
+
loopLimit?: number | undefined;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
|
|
47
|
+
* 20ms for every 20ms change in the real system time) (default: false)
|
|
48
|
+
*/
|
|
49
|
+
shouldAdvanceTime?: boolean | undefined;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
|
|
53
|
+
* in the real system time (default: 20)
|
|
54
|
+
*/
|
|
55
|
+
advanceTimeDelta?: number | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
shouldClearNativeTimers?: boolean | undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Config that tests have access to.
|
|
66
|
+
*/
|
|
67
|
+
interface SerializedConfig {
|
|
68
|
+
name: string | undefined;
|
|
69
|
+
globals: boolean;
|
|
70
|
+
base: string | undefined;
|
|
71
|
+
snapshotEnvironment?: string;
|
|
72
|
+
disableConsoleIntercept: boolean | undefined;
|
|
73
|
+
runner: string | undefined;
|
|
74
|
+
isolate: boolean;
|
|
75
|
+
mode: 'test' | 'benchmark';
|
|
76
|
+
bail: number | undefined;
|
|
77
|
+
environmentOptions?: Record<string, any>;
|
|
78
|
+
root: string;
|
|
79
|
+
setupFiles: string[];
|
|
80
|
+
passWithNoTests: boolean;
|
|
81
|
+
testNamePattern: RegExp | undefined;
|
|
82
|
+
allowOnly: boolean;
|
|
83
|
+
testTimeout: number;
|
|
84
|
+
hookTimeout: number;
|
|
85
|
+
clearMocks: boolean;
|
|
86
|
+
mockReset: boolean;
|
|
87
|
+
restoreMocks: boolean;
|
|
88
|
+
unstubGlobals: boolean;
|
|
89
|
+
unstubEnvs: boolean;
|
|
90
|
+
fakeTimers: FakeTimerInstallOpts;
|
|
91
|
+
maxConcurrency: number;
|
|
92
|
+
defines: Record<string, any>;
|
|
93
|
+
expect: {
|
|
94
|
+
requireAssertions?: boolean;
|
|
95
|
+
poll?: {
|
|
96
|
+
timeout?: number;
|
|
97
|
+
interval?: number;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
printConsoleTrace: boolean | undefined;
|
|
101
|
+
sequence: {
|
|
102
|
+
shuffle?: boolean;
|
|
103
|
+
concurrent?: boolean;
|
|
104
|
+
seed: number;
|
|
105
|
+
hooks: SequenceHooks;
|
|
106
|
+
setupFiles: SequenceSetupFiles;
|
|
107
|
+
};
|
|
108
|
+
poolOptions: {
|
|
109
|
+
forks: {
|
|
110
|
+
singleFork: boolean;
|
|
111
|
+
isolate: boolean;
|
|
112
|
+
};
|
|
113
|
+
threads: {
|
|
114
|
+
singleThread: boolean;
|
|
115
|
+
isolate: boolean;
|
|
116
|
+
};
|
|
117
|
+
vmThreads: {
|
|
118
|
+
singleThread: boolean;
|
|
119
|
+
};
|
|
120
|
+
vmForks: {
|
|
121
|
+
singleFork: boolean;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
deps: {
|
|
125
|
+
web: {
|
|
126
|
+
transformAssets?: boolean;
|
|
127
|
+
transformCss?: boolean;
|
|
128
|
+
transformGlobPattern?: RegExp | RegExp[];
|
|
129
|
+
};
|
|
130
|
+
optimizer: {
|
|
131
|
+
web: {
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
};
|
|
134
|
+
ssr: {
|
|
135
|
+
enabled: boolean;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
interopDefault: boolean | undefined;
|
|
139
|
+
moduleDirectories: string[] | undefined;
|
|
140
|
+
};
|
|
141
|
+
snapshotOptions: {
|
|
142
|
+
updateSnapshot: SnapshotUpdateState;
|
|
143
|
+
expand: boolean | undefined;
|
|
144
|
+
snapshotFormat: PrettyFormatOptions | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* only exists for tests, not available in the main process
|
|
147
|
+
*/
|
|
148
|
+
snapshotEnvironment: SnapshotEnvironment;
|
|
149
|
+
};
|
|
150
|
+
pool: string;
|
|
151
|
+
snapshotSerializers: string[];
|
|
152
|
+
chaiConfig: {
|
|
153
|
+
includeStack?: boolean;
|
|
154
|
+
showDiff?: boolean;
|
|
155
|
+
truncateThreshold?: number;
|
|
156
|
+
} | undefined;
|
|
157
|
+
diff: string | undefined;
|
|
158
|
+
retry: number;
|
|
159
|
+
includeTaskLocation: boolean | undefined;
|
|
160
|
+
inspect: boolean | string | undefined;
|
|
161
|
+
inspectBrk: boolean | string | undefined;
|
|
162
|
+
inspector: {
|
|
163
|
+
enabled?: boolean;
|
|
164
|
+
port?: number;
|
|
165
|
+
host?: string;
|
|
166
|
+
waitForDebugger?: boolean;
|
|
167
|
+
};
|
|
168
|
+
watch: boolean;
|
|
169
|
+
env: Record<string, any>;
|
|
170
|
+
browser: {
|
|
171
|
+
name: string;
|
|
172
|
+
headless: boolean;
|
|
173
|
+
isolate: boolean;
|
|
174
|
+
fileParallelism: boolean;
|
|
175
|
+
ui: boolean;
|
|
176
|
+
viewport: {
|
|
177
|
+
width: number;
|
|
178
|
+
height: number;
|
|
179
|
+
};
|
|
180
|
+
screenshotFailures: boolean;
|
|
181
|
+
};
|
|
182
|
+
standalone: boolean;
|
|
183
|
+
logHeapUsage: boolean | undefined;
|
|
184
|
+
coverage: SerializedCoverageConfig;
|
|
185
|
+
}
|
|
186
|
+
interface SerializedCoverageConfig {
|
|
187
|
+
provider: 'istanbul' | 'v8' | 'custom' | undefined;
|
|
188
|
+
reportsDirectory: string;
|
|
189
|
+
htmlReporter: {
|
|
190
|
+
subdir: string | undefined;
|
|
191
|
+
} | undefined;
|
|
192
|
+
enabled: boolean;
|
|
193
|
+
customProviderModule: string | undefined;
|
|
194
|
+
}
|
|
195
|
+
type RuntimeConfig = Pick<SerializedConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency' | 'expect' | 'printConsoleTrace'> & {
|
|
196
|
+
sequence?: {
|
|
197
|
+
concurrent?: boolean;
|
|
198
|
+
hooks?: SequenceHooks;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
type RuntimeOptions = Partial<RuntimeConfig>;
|
|
202
|
+
|
|
203
|
+
export type { FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedConfig as S, SerializedCoverageConfig as a, RuntimeConfig as b };
|
|
@@ -3,17 +3,16 @@ import { Console } from 'node:console';
|
|
|
3
3
|
import { relative } from 'node:path';
|
|
4
4
|
import { getSafeTimers } from '@vitest/utils';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import { R as RealDate } from '
|
|
6
|
+
import { R as RealDate } from './date.W2xKR2qe.js';
|
|
7
7
|
import 'pathe';
|
|
8
8
|
import '@vitest/runner/utils';
|
|
9
|
-
import { g as getWorkerState } from '
|
|
10
|
-
import '
|
|
9
|
+
import { g as getWorkerState } from './utils.Ck2hJTRs.js';
|
|
10
|
+
import './env.BU041cs9.js';
|
|
11
11
|
import 'std-env';
|
|
12
12
|
|
|
13
13
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
14
14
|
function getTaskIdByStack(root) {
|
|
15
|
-
|
|
16
|
-
const stack = (_a = new Error("STACK_TRACE_ERROR").stack) == null ? void 0 : _a.split("\n");
|
|
15
|
+
const stack = new Error("STACK_TRACE_ERROR").stack?.split("\n");
|
|
17
16
|
if (!stack) {
|
|
18
17
|
return UNKNOWN_TEST_ID;
|
|
19
18
|
}
|
|
@@ -22,7 +21,7 @@ function getTaskIdByStack(root) {
|
|
|
22
21
|
if (!line) {
|
|
23
22
|
return UNKNOWN_TEST_ID;
|
|
24
23
|
}
|
|
25
|
-
const filepath =
|
|
24
|
+
const filepath = line.match(/at\s(.*)\s?/)?.[1];
|
|
26
25
|
if (filepath) {
|
|
27
26
|
return relative(root, filepath);
|
|
28
27
|
}
|
|
@@ -90,9 +89,8 @@ function createCustomConsole(defaultState) {
|
|
|
90
89
|
}
|
|
91
90
|
const stdout = new Writable({
|
|
92
91
|
write(data, encoding, callback) {
|
|
93
|
-
var _a, _b, _c, _d;
|
|
94
92
|
const s = state();
|
|
95
|
-
const id =
|
|
93
|
+
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
96
94
|
let timer = timers.get(id);
|
|
97
95
|
if (timer) {
|
|
98
96
|
timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
|
@@ -113,7 +111,7 @@ function createCustomConsole(defaultState) {
|
|
|
113
111
|
const limit = Error.stackTraceLimit;
|
|
114
112
|
Error.stackTraceLimit = limit + 6;
|
|
115
113
|
const stack = new Error("STACK_TRACE").stack;
|
|
116
|
-
const trace = stack
|
|
114
|
+
const trace = stack?.split("\n").slice(7).join("\n");
|
|
117
115
|
Error.stackTraceLimit = limit;
|
|
118
116
|
buffer.push([data, trace]);
|
|
119
117
|
} else {
|
|
@@ -125,9 +123,8 @@ function createCustomConsole(defaultState) {
|
|
|
125
123
|
});
|
|
126
124
|
const stderr = new Writable({
|
|
127
125
|
write(data, encoding, callback) {
|
|
128
|
-
var _a, _b, _c, _d, _e;
|
|
129
126
|
const s = state();
|
|
130
|
-
const id =
|
|
127
|
+
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
131
128
|
let timer = timers.get(id);
|
|
132
129
|
if (timer) {
|
|
133
130
|
timer.stderrTime = timer.stderrTime || RealDate.now();
|
|
@@ -147,15 +144,15 @@ function createCustomConsole(defaultState) {
|
|
|
147
144
|
if (state().config.printConsoleTrace) {
|
|
148
145
|
const limit = Error.stackTraceLimit;
|
|
149
146
|
Error.stackTraceLimit = limit + 6;
|
|
150
|
-
const stack =
|
|
147
|
+
const stack = new Error("STACK_TRACE").stack?.split("\n");
|
|
151
148
|
Error.stackTraceLimit = limit;
|
|
152
|
-
const isTrace = stack
|
|
149
|
+
const isTrace = stack?.some(
|
|
153
150
|
(line) => line.includes("at Console.trace")
|
|
154
151
|
);
|
|
155
152
|
if (isTrace) {
|
|
156
153
|
buffer.push([data, void 0]);
|
|
157
154
|
} else {
|
|
158
|
-
const trace = stack
|
|
155
|
+
const trace = stack?.slice(7).join("\n");
|
|
159
156
|
Error.stackTraceLimit = limit;
|
|
160
157
|
buffer.push([data, trace]);
|
|
161
158
|
}
|
|
@@ -6,9 +6,7 @@ const extraInlineDeps = [
|
|
|
6
6
|
/^(?!.*node_modules).*\.mjs$/,
|
|
7
7
|
/^(?!.*node_modules).*\.cjs\.js$/,
|
|
8
8
|
// Vite client
|
|
9
|
-
/vite\w*\/dist\/client\/env.mjs
|
|
10
|
-
// Nuxt
|
|
11
|
-
"@nuxt/test-utils"
|
|
9
|
+
/vite\w*\/dist\/client\/env.mjs/
|
|
12
10
|
];
|
|
13
11
|
const CONFIG_NAMES = ["vitest.config", "vite.config"];
|
|
14
12
|
const WORKSPACES_NAMES = ["vitest.workspace", "vitest.projects"];
|
|
@@ -3,7 +3,7 @@ const CoverageProviderMap = {
|
|
|
3
3
|
istanbul: "@vitest/coverage-istanbul"
|
|
4
4
|
};
|
|
5
5
|
async function resolveCoverageProviderModule(options, loader) {
|
|
6
|
-
if (!
|
|
6
|
+
if (!options?.enabled || !options.provider) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
const provider = options.provider;
|
|
@@ -42,26 +42,23 @@ async function getCoverageProvider(options, loader) {
|
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
async function startCoverageInsideWorker(options, loader) {
|
|
45
|
-
var _a;
|
|
46
45
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
47
46
|
if (coverageModule) {
|
|
48
|
-
return
|
|
47
|
+
return coverageModule.startCoverage?.();
|
|
49
48
|
}
|
|
50
49
|
return null;
|
|
51
50
|
}
|
|
52
51
|
async function takeCoverageInsideWorker(options, loader) {
|
|
53
|
-
var _a;
|
|
54
52
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
55
53
|
if (coverageModule) {
|
|
56
|
-
return
|
|
54
|
+
return coverageModule.takeCoverage?.();
|
|
57
55
|
}
|
|
58
56
|
return null;
|
|
59
57
|
}
|
|
60
58
|
async function stopCoverageInsideWorker(options, loader) {
|
|
61
|
-
var _a;
|
|
62
59
|
const coverageModule = await resolveCoverageProviderModule(options, loader);
|
|
63
60
|
if (coverageModule) {
|
|
64
|
-
return
|
|
61
|
+
return coverageModule.stopCoverage?.();
|
|
65
62
|
}
|
|
66
63
|
return null;
|
|
67
64
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { resolve, dirname, relative } from 'node:path';
|
|
2
2
|
import { existsSync, writeFileSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { p as prompt, f as findUp } from '
|
|
4
|
+
import { p as prompt, f as findUp } from './index.CM5UI-4O.js';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import { detectPackageManager, installPackage } from './
|
|
6
|
+
import { detectPackageManager, installPackage } from './index.DNUmWFkO.js';
|
|
7
7
|
import { execa } from 'execa';
|
|
8
|
-
import { c as configFiles } from '
|
|
8
|
+
import { c as configFiles } from './constants.CaAN7icJ.js';
|
|
9
9
|
import 'node:url';
|
|
10
10
|
import 'node:process';
|
|
11
|
-
import '
|
|
11
|
+
import './_commonjsHelpers.BFTU3MAI.js';
|
|
12
12
|
import 'readline';
|
|
13
13
|
import 'events';
|
|
14
14
|
import 'fs';
|
|
@@ -552,7 +552,7 @@ async function create() {
|
|
|
552
552
|
type: "select",
|
|
553
553
|
name: "lang",
|
|
554
554
|
message: "Choose a language for your tests",
|
|
555
|
-
choices: sort(getLanguageOptions(), defaults
|
|
555
|
+
choices: sort(getLanguageOptions(), defaults?.lang)
|
|
556
556
|
});
|
|
557
557
|
if (!lang) {
|
|
558
558
|
return fail();
|
|
@@ -561,7 +561,7 @@ async function create() {
|
|
|
561
561
|
type: "select",
|
|
562
562
|
name: "provider",
|
|
563
563
|
message: "Choose a browser provider. Vitest will use its API to control the testing environment",
|
|
564
|
-
choices: sort(getProviderOptions(), defaults
|
|
564
|
+
choices: sort(getProviderOptions(), defaults?.provider)
|
|
565
565
|
});
|
|
566
566
|
if (!provider) {
|
|
567
567
|
return fail();
|
|
@@ -582,7 +582,7 @@ async function create() {
|
|
|
582
582
|
type: "select",
|
|
583
583
|
name: "framework",
|
|
584
584
|
message: "Choose your framework",
|
|
585
|
-
choices: sort(getFramework(), defaults
|
|
585
|
+
choices: sort(getFramework(), defaults?.framework)
|
|
586
586
|
});
|
|
587
587
|
if (!framework) {
|
|
588
588
|
return fail();
|
|
@@ -660,7 +660,7 @@ async function create() {
|
|
|
660
660
|
});
|
|
661
661
|
}
|
|
662
662
|
if (lang === "ts") {
|
|
663
|
-
await updateTsConfig(providerPkg
|
|
663
|
+
await updateTsConfig(providerPkg?.types);
|
|
664
664
|
}
|
|
665
665
|
log();
|
|
666
666
|
const exampleTestFile = await generateExampleFiles(framework, lang);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import 'std-env';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const isDeno = typeof process < "u" && typeof process.stdout < "u" && ((_b = process.versions) == null ? void 0 : _b.deno) !== void 0;
|
|
3
|
+
const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
|
|
4
|
+
const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
|
|
6
5
|
const isWindows = (isNode || isDeno) && process.platform === "win32";
|
|
7
6
|
|
|
8
7
|
export { isDeno as a, isWindows as b, isNode as i };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
2
|
+
type Nullable<T> = T | null | undefined;
|
|
3
|
+
type Arrayable<T> = T | Array<T>;
|
|
4
|
+
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
5
|
+
type MutableArray<T extends readonly any[]> = {
|
|
6
|
+
-readonly [k in keyof T]: T[k];
|
|
7
|
+
};
|
|
8
|
+
interface Constructable {
|
|
9
|
+
new (...args: any[]): any;
|
|
10
|
+
}
|
|
11
|
+
type TransformMode = 'web' | 'ssr';
|
|
12
|
+
/** @deprecated not used */
|
|
13
|
+
interface ModuleCache {
|
|
14
|
+
promise?: Promise<any>;
|
|
15
|
+
exports?: any;
|
|
16
|
+
code?: string;
|
|
17
|
+
}
|
|
18
|
+
interface AfterSuiteRunMeta {
|
|
19
|
+
coverage?: unknown;
|
|
20
|
+
transformMode: TransformMode;
|
|
21
|
+
projectName?: string;
|
|
22
|
+
}
|
|
23
|
+
interface UserConsoleLog {
|
|
24
|
+
content: string;
|
|
25
|
+
origin?: string;
|
|
26
|
+
browser?: boolean;
|
|
27
|
+
type: 'stdout' | 'stderr';
|
|
28
|
+
taskId?: string;
|
|
29
|
+
time: number;
|
|
30
|
+
size: number;
|
|
31
|
+
}
|
|
32
|
+
interface ModuleGraphData {
|
|
33
|
+
graph: Record<string, string[]>;
|
|
34
|
+
externalized: string[];
|
|
35
|
+
inlined: string[];
|
|
36
|
+
}
|
|
37
|
+
type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
|
|
38
|
+
interface ProvidedContext {
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface JSDOMOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The html content for the test.
|
|
44
|
+
*
|
|
45
|
+
* @default '<!DOCTYPE html>'
|
|
46
|
+
*/
|
|
47
|
+
html?: string | ArrayBufferLike;
|
|
48
|
+
/**
|
|
49
|
+
* referrer just affects the value read from document.referrer.
|
|
50
|
+
* It defaults to no referrer (which reflects as the empty string).
|
|
51
|
+
*/
|
|
52
|
+
referrer?: string;
|
|
53
|
+
/**
|
|
54
|
+
* userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
|
|
55
|
+
*
|
|
56
|
+
* @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
|
|
57
|
+
*/
|
|
58
|
+
userAgent?: string;
|
|
59
|
+
/**
|
|
60
|
+
* url sets the value returned by window.location, document.URL, and document.documentURI,
|
|
61
|
+
* and affects things like resolution of relative URLs within the document
|
|
62
|
+
* and the same-origin restrictions and referrer used while fetching subresources.
|
|
63
|
+
*
|
|
64
|
+
* @default 'http://localhost:3000'.
|
|
65
|
+
*/
|
|
66
|
+
url?: string;
|
|
67
|
+
/**
|
|
68
|
+
* contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
|
|
69
|
+
* Values that are not "text/html" or an XML mime type will throw.
|
|
70
|
+
*
|
|
71
|
+
* @default 'text/html'.
|
|
72
|
+
*/
|
|
73
|
+
contentType?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
|
|
76
|
+
* Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
|
|
77
|
+
* to 5,000,000 code units per origin, as inspired by the HTML specification.
|
|
78
|
+
*
|
|
79
|
+
* @default 5_000_000
|
|
80
|
+
*/
|
|
81
|
+
storageQuota?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Enable console?
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
console?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* jsdom does not have the capability to render visual content, and will act like a headless browser by default.
|
|
90
|
+
* It provides hints to web pages through APIs such as document.hidden that their content is not visible.
|
|
91
|
+
*
|
|
92
|
+
* When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
|
|
93
|
+
* content.
|
|
94
|
+
*
|
|
95
|
+
* @default true
|
|
96
|
+
*/
|
|
97
|
+
pretendToBeVisual?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* `includeNodeLocations` preserves the location info produced by the HTML parser,
|
|
100
|
+
* allowing you to retrieve it with the nodeLocation() method (described below).
|
|
101
|
+
*
|
|
102
|
+
* It defaults to false to give the best performance,
|
|
103
|
+
* and cannot be used with an XML content type since our XML parser does not support location info.
|
|
104
|
+
*
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
includeNodeLocations?: boolean | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* @default 'dangerously'
|
|
110
|
+
*/
|
|
111
|
+
runScripts?: 'dangerously' | 'outside-only';
|
|
112
|
+
/**
|
|
113
|
+
* Enable CookieJar
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
cookieJar?: boolean;
|
|
118
|
+
resources?: 'usable';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Happy DOM options.
|
|
123
|
+
*/
|
|
124
|
+
interface HappyDOMOptions {
|
|
125
|
+
width?: number;
|
|
126
|
+
height?: number;
|
|
127
|
+
url?: string;
|
|
128
|
+
settings?: {
|
|
129
|
+
disableJavaScriptEvaluation?: boolean;
|
|
130
|
+
disableJavaScriptFileLoading?: boolean;
|
|
131
|
+
disableCSSFileLoading?: boolean;
|
|
132
|
+
disableIframePageLoading?: boolean;
|
|
133
|
+
disableComputedStyleRendering?: boolean;
|
|
134
|
+
enableFileSystemHttpRequests?: boolean;
|
|
135
|
+
navigator?: {
|
|
136
|
+
userAgent?: string;
|
|
137
|
+
};
|
|
138
|
+
device?: {
|
|
139
|
+
prefersColorScheme?: string;
|
|
140
|
+
mediaType?: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface EnvironmentReturn {
|
|
146
|
+
teardown: (global: any) => Awaitable<void>;
|
|
147
|
+
}
|
|
148
|
+
interface VmEnvironmentReturn {
|
|
149
|
+
getVmContext: () => {
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
};
|
|
152
|
+
teardown: () => Awaitable<void>;
|
|
153
|
+
}
|
|
154
|
+
interface Environment {
|
|
155
|
+
name: string;
|
|
156
|
+
transformMode: 'web' | 'ssr';
|
|
157
|
+
setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
|
|
158
|
+
setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
|
|
159
|
+
}
|
|
160
|
+
interface EnvironmentOptions {
|
|
161
|
+
/**
|
|
162
|
+
* jsdom options.
|
|
163
|
+
*/
|
|
164
|
+
jsdom?: JSDOMOptions;
|
|
165
|
+
happyDOM?: HappyDOMOptions;
|
|
166
|
+
[x: string]: unknown;
|
|
167
|
+
}
|
|
168
|
+
interface ResolvedTestEnvironment {
|
|
169
|
+
environment: Environment;
|
|
170
|
+
options: Record<string, any> | null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export type { AfterSuiteRunMeta as A, Constructable as C, Environment as E, HappyDOMOptions as H, JSDOMOptions as J, ModuleGraphData as M, Nullable as N, OnServerRestartHandler as O, ProvidedContext as P, ResolvedTestEnvironment as R, TransformMode as T, UserConsoleLog as U, VmEnvironmentReturn as V, EnvironmentReturn as a, Awaitable as b, Arrayable as c, ArgumentsType as d, MutableArray as e, EnvironmentOptions as f, ModuleCache as g };
|