vitest 0.0.99 → 0.0.103
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 +0 -168
- package/dist/cli.js +8 -10
- package/dist/{constants-3cbd9066.js → constants-a1417084.js} +2 -2
- package/dist/entry.js +6 -5
- package/dist/{error-34c1d9e5.js → error-0e2f75a4.js} +7 -8
- package/dist/{global-0be1f687.js → global-12f52a87.js} +5 -5
- package/dist/{index-d5bb350e.js → index-6f17b444.js} +55 -40
- package/dist/{index-af51d171.js → index-a190f5a1.js} +2 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.js +4 -4
- package/dist/{middleware-991dfa87.js → middleware-05e03d95.js} +2 -2
- package/dist/node.d.ts +313 -0
- package/dist/node.js +4 -4
- package/dist/suite-64b3e636.js +201 -0
- package/dist/{utils-b780070b.js → utils-c8e62373.js} +1 -1
- package/dist/utils.js +1 -1
- package/dist/worker.js +2 -2
- package/node.d.ts +1 -0
- package/package.json +3 -3
- package/dist/index-aa25bceb.js +0 -11166
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, f as fn, s as spyOn, e as vi, v as vitest } from './index-
|
|
1
|
+
export { d as describe, i as it, s as suite, t as test } from './suite-64b3e636.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, f as fn, s as spyOn, e as vi, v as vitest } from './index-a190f5a1.js';
|
|
3
|
+
export { assert, default as chai, expect, should } from 'chai';
|
|
3
4
|
import './index-9e71c815.js';
|
|
4
|
-
import './utils-
|
|
5
|
+
import './utils-c8e62373.js';
|
|
5
6
|
import 'tty';
|
|
6
7
|
import 'local-pkg';
|
|
7
8
|
import 'path';
|
|
8
|
-
import './_commonjsHelpers-bdec4bbd.js';
|
|
9
9
|
import 'tinyspy';
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
|
+
import { OptionsReceived } from 'pretty-format';
|
|
3
|
+
|
|
4
|
+
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
5
|
+
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
6
|
+
interface UserConsoleLog {
|
|
7
|
+
content: string;
|
|
8
|
+
type: 'stdout' | 'stderr';
|
|
9
|
+
taskId?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
13
|
+
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
14
|
+
declare type ComputeMode = 'serial' | 'concurrent';
|
|
15
|
+
interface TaskBase {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
mode: RunMode;
|
|
19
|
+
computeMode: ComputeMode;
|
|
20
|
+
suite?: Suite;
|
|
21
|
+
file?: File;
|
|
22
|
+
result?: TaskResult;
|
|
23
|
+
}
|
|
24
|
+
interface TaskResult {
|
|
25
|
+
state: TaskState;
|
|
26
|
+
start: number;
|
|
27
|
+
end?: number;
|
|
28
|
+
error?: unknown;
|
|
29
|
+
}
|
|
30
|
+
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
31
|
+
interface Suite extends TaskBase {
|
|
32
|
+
type: 'suite';
|
|
33
|
+
tasks: Task[];
|
|
34
|
+
}
|
|
35
|
+
interface File extends Suite {
|
|
36
|
+
filepath: string;
|
|
37
|
+
}
|
|
38
|
+
interface Test extends TaskBase {
|
|
39
|
+
type: 'test';
|
|
40
|
+
suite: Suite;
|
|
41
|
+
result?: TaskResult;
|
|
42
|
+
fails?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare type Task = Test | Suite | File;
|
|
45
|
+
|
|
46
|
+
interface Reporter {
|
|
47
|
+
onStart?: (files?: string[]) => Awaitable<void>;
|
|
48
|
+
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
49
|
+
onTaskUpdate?: (pack: TaskResultPack) => Awaitable<void>;
|
|
50
|
+
onWatcherStart?: () => Awaitable<void>;
|
|
51
|
+
onWatcherRerun?: (files: string[], trigger: string) => Awaitable<void>;
|
|
52
|
+
onServerRestart?: () => Awaitable<void>;
|
|
53
|
+
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare type SnapshotUpdateState = 'all' | 'new' | 'none';
|
|
57
|
+
declare type SnapshotStateOptions = {
|
|
58
|
+
updateSnapshot: SnapshotUpdateState;
|
|
59
|
+
expand?: boolean;
|
|
60
|
+
snapshotFormat?: OptionsReceived;
|
|
61
|
+
};
|
|
62
|
+
interface SnapshotResult {
|
|
63
|
+
filepath: string;
|
|
64
|
+
added: number;
|
|
65
|
+
fileDeleted: boolean;
|
|
66
|
+
matched: number;
|
|
67
|
+
unchecked: number;
|
|
68
|
+
uncheckedKeys: Array<string>;
|
|
69
|
+
unmatched: number;
|
|
70
|
+
updated: number;
|
|
71
|
+
}
|
|
72
|
+
interface UncheckedSnapshot {
|
|
73
|
+
filePath: string;
|
|
74
|
+
keys: Array<string>;
|
|
75
|
+
}
|
|
76
|
+
interface SnapshotSummary {
|
|
77
|
+
added: number;
|
|
78
|
+
didUpdate: boolean;
|
|
79
|
+
failure: boolean;
|
|
80
|
+
filesAdded: number;
|
|
81
|
+
filesRemoved: number;
|
|
82
|
+
filesRemovedList: Array<string>;
|
|
83
|
+
filesUnmatched: number;
|
|
84
|
+
filesUpdated: number;
|
|
85
|
+
matched: number;
|
|
86
|
+
total: number;
|
|
87
|
+
unchecked: number;
|
|
88
|
+
uncheckedKeysByFile: Array<UncheckedSnapshot>;
|
|
89
|
+
unmatched: number;
|
|
90
|
+
updated: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
94
|
+
interface InlineConfig {
|
|
95
|
+
/**
|
|
96
|
+
* Include globs for test files
|
|
97
|
+
*
|
|
98
|
+
* @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
|
|
99
|
+
*/
|
|
100
|
+
include?: string[];
|
|
101
|
+
/**
|
|
102
|
+
* Exclude globs for test files
|
|
103
|
+
* @default ['node_modules', 'dist', '.idea', '.git', '.cache']
|
|
104
|
+
*/
|
|
105
|
+
exclude?: string[];
|
|
106
|
+
/**
|
|
107
|
+
* Handling for dependencies inlining or externalizing
|
|
108
|
+
*/
|
|
109
|
+
deps?: {
|
|
110
|
+
/**
|
|
111
|
+
* Externalize means that Vite will bypass the package to native Node.
|
|
112
|
+
*
|
|
113
|
+
* Externalized dependencies will not be applied Vite's transformers and resolvers.
|
|
114
|
+
* And does not support HMR on reload.
|
|
115
|
+
*
|
|
116
|
+
* Typically, packages under `node_modules` are externalized.
|
|
117
|
+
*/
|
|
118
|
+
external?: (string | RegExp)[];
|
|
119
|
+
/**
|
|
120
|
+
* Vite will process inlined modules.
|
|
121
|
+
*
|
|
122
|
+
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
123
|
+
*/
|
|
124
|
+
inline?: (string | RegExp)[];
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Register apis globally
|
|
128
|
+
*
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
global?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Running environment
|
|
134
|
+
*
|
|
135
|
+
* Supports 'node', 'jsdom', 'happy-dom'
|
|
136
|
+
*
|
|
137
|
+
* @default 'node'
|
|
138
|
+
*/
|
|
139
|
+
environment?: BuiltinEnvironment;
|
|
140
|
+
/**
|
|
141
|
+
* Update snapshot files
|
|
142
|
+
*
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
update?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Watch mode
|
|
148
|
+
*
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
watch?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Project root
|
|
154
|
+
*/
|
|
155
|
+
root?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Custom reporter for output
|
|
158
|
+
*/
|
|
159
|
+
reporters?: Reporter | Reporter[];
|
|
160
|
+
/**
|
|
161
|
+
* Enable multi-threading
|
|
162
|
+
*
|
|
163
|
+
* @default true
|
|
164
|
+
*/
|
|
165
|
+
threads?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Maximum number of threads
|
|
168
|
+
*
|
|
169
|
+
* @default available CPUs
|
|
170
|
+
*/
|
|
171
|
+
maxThreads?: number;
|
|
172
|
+
/**
|
|
173
|
+
* Minimum number of threads
|
|
174
|
+
*
|
|
175
|
+
* @default available CPUs
|
|
176
|
+
*/
|
|
177
|
+
minThreads?: number;
|
|
178
|
+
interpretDefault?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Default timeout of a test in milliseconds
|
|
181
|
+
*
|
|
182
|
+
* @default 5000
|
|
183
|
+
*/
|
|
184
|
+
testTimeout?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Default timeout of a hook in milliseconds
|
|
187
|
+
*
|
|
188
|
+
* @default 5000
|
|
189
|
+
*/
|
|
190
|
+
hookTimeout?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Silent mode
|
|
193
|
+
*
|
|
194
|
+
* @default false
|
|
195
|
+
*/
|
|
196
|
+
silent?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Path to setup files
|
|
199
|
+
*/
|
|
200
|
+
setupFiles?: string | string[];
|
|
201
|
+
/**
|
|
202
|
+
* Pattern of file paths to be ignore from triggering watch rerun
|
|
203
|
+
*
|
|
204
|
+
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
205
|
+
*/
|
|
206
|
+
watchIgnore?: (string | RegExp)[];
|
|
207
|
+
/**
|
|
208
|
+
* Open Vitest UI
|
|
209
|
+
* @internal WIP
|
|
210
|
+
*/
|
|
211
|
+
open?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Listen to port and serve API
|
|
214
|
+
*
|
|
215
|
+
* When set to true, the default port is 55555
|
|
216
|
+
*
|
|
217
|
+
* @internal WIP
|
|
218
|
+
* @default false
|
|
219
|
+
*/
|
|
220
|
+
api?: boolean | number;
|
|
221
|
+
}
|
|
222
|
+
interface UserConfig extends InlineConfig {
|
|
223
|
+
/**
|
|
224
|
+
* Path to the config file.
|
|
225
|
+
*
|
|
226
|
+
* Default resolving to one of:
|
|
227
|
+
* - `vitest.config.js`
|
|
228
|
+
* - `vitest.config.ts`
|
|
229
|
+
* - `vite.config.js`
|
|
230
|
+
* - `vite.config.ts`
|
|
231
|
+
*/
|
|
232
|
+
config?: string | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Use happy-dom
|
|
235
|
+
*/
|
|
236
|
+
dom?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Do not watch
|
|
239
|
+
*/
|
|
240
|
+
run?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Pass with no tests
|
|
243
|
+
*/
|
|
244
|
+
passWithNoTests?: boolean;
|
|
245
|
+
}
|
|
246
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'> {
|
|
247
|
+
config?: string;
|
|
248
|
+
filters?: string[];
|
|
249
|
+
depsInline: (string | RegExp)[];
|
|
250
|
+
depsExternal: (string | RegExp)[];
|
|
251
|
+
snapshotOptions: SnapshotStateOptions;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare class SnapshotManager {
|
|
255
|
+
config: ResolvedConfig;
|
|
256
|
+
summary: SnapshotSummary;
|
|
257
|
+
constructor(config: ResolvedConfig);
|
|
258
|
+
clear(): void;
|
|
259
|
+
add(result: SnapshotResult): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
263
|
+
interface WorkerPool {
|
|
264
|
+
runTests: RunWithFiles;
|
|
265
|
+
collectTests: RunWithFiles;
|
|
266
|
+
close: () => Promise<void>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
declare class StateManager {
|
|
270
|
+
filesMap: Record<string, File>;
|
|
271
|
+
idMap: Record<string, Task>;
|
|
272
|
+
taskFileMap: WeakMap<Task, File>;
|
|
273
|
+
getFiles(keys?: string[]): File[];
|
|
274
|
+
collectFiles(files: File[]): void;
|
|
275
|
+
updateId(task: Task): void;
|
|
276
|
+
updateTasks(packs: TaskResultPack[]): void;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
declare class Vitest {
|
|
280
|
+
config: ResolvedConfig;
|
|
281
|
+
server: ViteDevServer;
|
|
282
|
+
state: StateManager;
|
|
283
|
+
snapshot: SnapshotManager;
|
|
284
|
+
reporters: Reporter[];
|
|
285
|
+
console: Console;
|
|
286
|
+
pool: WorkerPool | undefined;
|
|
287
|
+
invalidates: Set<string>;
|
|
288
|
+
changedTests: Set<string>;
|
|
289
|
+
runningPromise?: Promise<void>;
|
|
290
|
+
isFirstRun: boolean;
|
|
291
|
+
restartsCount: number;
|
|
292
|
+
private _onRestartListeners;
|
|
293
|
+
constructor();
|
|
294
|
+
setServer(options: UserConfig, server: ViteDevServer): void;
|
|
295
|
+
start(filters?: string[]): Promise<void>;
|
|
296
|
+
runFiles(files: string[]): Promise<void>;
|
|
297
|
+
log(...args: any[]): void;
|
|
298
|
+
error(...args: any[]): void;
|
|
299
|
+
private _rerunTimer;
|
|
300
|
+
private scheduleRerun;
|
|
301
|
+
private unregisterWatcher;
|
|
302
|
+
private registerWatcher;
|
|
303
|
+
private handleFileChanged;
|
|
304
|
+
close(): Promise<void>;
|
|
305
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
306
|
+
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
307
|
+
isTargetFile(id: string): boolean;
|
|
308
|
+
onServerRestarted(fn: () => void): void;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
declare function createVitest(options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
|
|
312
|
+
|
|
313
|
+
export { Vitest, createVitest };
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import './utils-
|
|
1
|
+
export { c as createVitest } from './index-6f17b444.js';
|
|
2
|
+
import './utils-c8e62373.js';
|
|
3
3
|
import 'tty';
|
|
4
4
|
import 'local-pkg';
|
|
5
5
|
import 'path';
|
|
@@ -10,10 +10,10 @@ import 'os';
|
|
|
10
10
|
import 'util';
|
|
11
11
|
import 'stream';
|
|
12
12
|
import 'events';
|
|
13
|
-
import './constants-
|
|
13
|
+
import './constants-a1417084.js';
|
|
14
14
|
import 'url';
|
|
15
15
|
import 'perf_hooks';
|
|
16
|
-
import './error-
|
|
16
|
+
import './error-0e2f75a4.js';
|
|
17
17
|
import './index-825cb54c.js';
|
|
18
18
|
import './_commonjsHelpers-bdec4bbd.js';
|
|
19
19
|
import 'assert';
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { n as nanoid } from './index-9e71c815.js';
|
|
2
|
+
import { n as noop } from './utils-c8e62373.js';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
function createChainable(keys, fn) {
|
|
24
|
+
function create(obj) {
|
|
25
|
+
const chain2 = function(...args) {
|
|
26
|
+
return fn.apply(obj, args);
|
|
27
|
+
};
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
Object.defineProperty(chain2, key, {
|
|
30
|
+
get() {
|
|
31
|
+
return create(__spreadProps(__spreadValues({}, obj), { [key]: true }));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return chain2;
|
|
36
|
+
}
|
|
37
|
+
const chain = create({});
|
|
38
|
+
chain.fn = fn;
|
|
39
|
+
return chain;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const context = {
|
|
43
|
+
tasks: [],
|
|
44
|
+
currentSuite: null
|
|
45
|
+
};
|
|
46
|
+
function collectTask(task) {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = context.currentSuite) == null ? void 0 : _a.tasks.push(task);
|
|
49
|
+
}
|
|
50
|
+
async function runWithSuite(suite, fn) {
|
|
51
|
+
const prev = context.currentSuite;
|
|
52
|
+
context.currentSuite = suite;
|
|
53
|
+
await fn();
|
|
54
|
+
context.currentSuite = prev;
|
|
55
|
+
}
|
|
56
|
+
function getDefaultTestTimeout() {
|
|
57
|
+
return process.__vitest_worker__.config.testTimeout;
|
|
58
|
+
}
|
|
59
|
+
function getDefaultHookTimeout() {
|
|
60
|
+
return process.__vitest_worker__.config.hookTimeout;
|
|
61
|
+
}
|
|
62
|
+
function withTimeout(fn, _timeout) {
|
|
63
|
+
const timeout = _timeout ?? getDefaultTestTimeout();
|
|
64
|
+
if (timeout <= 0 || timeout === Infinity)
|
|
65
|
+
return fn;
|
|
66
|
+
return (...args) => {
|
|
67
|
+
return Promise.race([fn(...args), new Promise((resolve, reject) => {
|
|
68
|
+
const timer = setTimeout(() => {
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
reject(new Error(`Test timed out in ${timeout}ms.`));
|
|
71
|
+
}, timeout);
|
|
72
|
+
timer.unref();
|
|
73
|
+
})]);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function ensureAsyncTest(fn) {
|
|
77
|
+
if (!fn.length)
|
|
78
|
+
return fn;
|
|
79
|
+
return () => new Promise((resolve, reject) => {
|
|
80
|
+
const done = (...args) => args[0] ? reject(args[0]) : resolve();
|
|
81
|
+
fn(done);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function normalizeTest(fn, timeout) {
|
|
85
|
+
return withTimeout(ensureAsyncTest(fn), timeout);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const fnMap = /* @__PURE__ */ new WeakMap();
|
|
89
|
+
const hooksMap = /* @__PURE__ */ new WeakMap();
|
|
90
|
+
function setFn(key, fn) {
|
|
91
|
+
fnMap.set(key, fn);
|
|
92
|
+
}
|
|
93
|
+
function getFn(key) {
|
|
94
|
+
return fnMap.get(key);
|
|
95
|
+
}
|
|
96
|
+
function setHooks(key, hooks) {
|
|
97
|
+
hooksMap.set(key, hooks);
|
|
98
|
+
}
|
|
99
|
+
function getHooks(key) {
|
|
100
|
+
return hooksMap.get(key);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const suite = createSuite();
|
|
104
|
+
const test = createChainable(["concurrent", "skip", "only", "todo", "fails"], function(name, fn, timeout) {
|
|
105
|
+
getCurrentSuite().test.fn.call(this, name, fn, timeout);
|
|
106
|
+
});
|
|
107
|
+
const describe = suite;
|
|
108
|
+
const it = test;
|
|
109
|
+
const defaultSuite = suite("");
|
|
110
|
+
function clearContext() {
|
|
111
|
+
context.tasks.length = 0;
|
|
112
|
+
defaultSuite.clear();
|
|
113
|
+
context.currentSuite = defaultSuite;
|
|
114
|
+
}
|
|
115
|
+
function getCurrentSuite() {
|
|
116
|
+
return context.currentSuite || defaultSuite;
|
|
117
|
+
}
|
|
118
|
+
function createSuiteHooks() {
|
|
119
|
+
return {
|
|
120
|
+
beforeAll: [],
|
|
121
|
+
afterAll: [],
|
|
122
|
+
beforeEach: [],
|
|
123
|
+
afterEach: []
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function createSuiteCollector(name, factory = () => {
|
|
127
|
+
}, mode, suiteComputeMode) {
|
|
128
|
+
const tasks = [];
|
|
129
|
+
const factoryQueue = [];
|
|
130
|
+
let suite2;
|
|
131
|
+
initSuite();
|
|
132
|
+
const test2 = createChainable(["concurrent", "skip", "only", "todo", "fails"], function(name2, fn, timeout) {
|
|
133
|
+
const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
134
|
+
const computeMode = this.concurrent ? "concurrent" : void 0;
|
|
135
|
+
const test3 = {
|
|
136
|
+
id: nanoid(),
|
|
137
|
+
type: "test",
|
|
138
|
+
name: name2,
|
|
139
|
+
mode: mode2,
|
|
140
|
+
computeMode: computeMode ?? (suiteComputeMode ?? "serial"),
|
|
141
|
+
suite: void 0,
|
|
142
|
+
fails: this.fails
|
|
143
|
+
};
|
|
144
|
+
setFn(test3, normalizeTest(fn || noop, timeout));
|
|
145
|
+
tasks.push(test3);
|
|
146
|
+
});
|
|
147
|
+
const collector = {
|
|
148
|
+
type: "collector",
|
|
149
|
+
name,
|
|
150
|
+
mode,
|
|
151
|
+
test: test2,
|
|
152
|
+
tasks,
|
|
153
|
+
collect,
|
|
154
|
+
clear,
|
|
155
|
+
on: addHook
|
|
156
|
+
};
|
|
157
|
+
function addHook(name2, ...fn) {
|
|
158
|
+
getHooks(suite2)[name2].push(...fn);
|
|
159
|
+
}
|
|
160
|
+
function initSuite() {
|
|
161
|
+
suite2 = {
|
|
162
|
+
id: nanoid(),
|
|
163
|
+
type: "suite",
|
|
164
|
+
computeMode: "serial",
|
|
165
|
+
name,
|
|
166
|
+
mode,
|
|
167
|
+
tasks: []
|
|
168
|
+
};
|
|
169
|
+
setHooks(suite2, createSuiteHooks());
|
|
170
|
+
}
|
|
171
|
+
function clear() {
|
|
172
|
+
tasks.length = 0;
|
|
173
|
+
factoryQueue.length = 0;
|
|
174
|
+
initSuite();
|
|
175
|
+
}
|
|
176
|
+
async function collect(file) {
|
|
177
|
+
factoryQueue.length = 0;
|
|
178
|
+
if (factory)
|
|
179
|
+
await runWithSuite(collector, () => factory(test2));
|
|
180
|
+
const allChildren = await Promise.all([...factoryQueue, ...tasks].map((i) => i.type === "collector" ? i.collect(file) : i));
|
|
181
|
+
suite2.file = file;
|
|
182
|
+
suite2.tasks = allChildren;
|
|
183
|
+
allChildren.forEach((task) => {
|
|
184
|
+
task.suite = suite2;
|
|
185
|
+
if (file)
|
|
186
|
+
task.file = file;
|
|
187
|
+
});
|
|
188
|
+
return suite2;
|
|
189
|
+
}
|
|
190
|
+
collectTask(collector);
|
|
191
|
+
return collector;
|
|
192
|
+
}
|
|
193
|
+
function createSuite() {
|
|
194
|
+
return createChainable(["concurrent", "skip", "only", "todo"], function(name, factory) {
|
|
195
|
+
const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
196
|
+
const computeMode = this.concurrent ? "concurrent" : void 0;
|
|
197
|
+
return createSuiteCollector(name, factory, mode, computeMode);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { getDefaultHookTimeout as a, defaultSuite as b, clearContext as c, describe as d, setHooks as e, getHooks as f, getCurrentSuite as g, context as h, it as i, getFn as j, suite as s, test as t, withTimeout as w };
|
|
@@ -323,7 +323,7 @@ function getNames(task) {
|
|
|
323
323
|
}
|
|
324
324
|
return names;
|
|
325
325
|
}
|
|
326
|
-
async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI) {
|
|
326
|
+
async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
|
|
327
327
|
if (isPackageExists(dependency))
|
|
328
328
|
return true;
|
|
329
329
|
console.log(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as ensurePackageInstalled, g as getNames, f as getSuites, q as getTasks, a as getTests, j as hasFailed, o as hasTests, m as interpretOnlyMode, n as noop, k as notNullish, p as partitionSuiteChildren, h as resolvePath, s as slash, t as toArray } from './utils-
|
|
1
|
+
export { e as ensurePackageInstalled, g as getNames, f as getSuites, q as getTasks, a as getTests, j as hasFailed, o as hasTests, m as interpretOnlyMode, n as noop, k as notNullish, p as partitionSuiteChildren, h as resolvePath, s as slash, t as toArray } from './utils-c8e62373.js';
|
|
2
2
|
import 'local-pkg';
|
|
3
3
|
import 'tty';
|
|
4
4
|
import 'path';
|
package/dist/worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as slash, h as resolve, d as dirname$2 } from './utils-
|
|
1
|
+
import { s as slash, h as resolve, d as dirname$2 } from './utils-c8e62373.js';
|
|
2
2
|
import { n as nanoid } from './index-9e71c815.js';
|
|
3
|
-
import { c as distDir } from './constants-
|
|
3
|
+
import { c as distDir } from './constants-a1417084.js';
|
|
4
4
|
import { builtinModules, createRequire } from 'module';
|
|
5
5
|
import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
|
|
6
6
|
import vm from 'vm';
|
package/node.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/node'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.103",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@types/chai": "^4.3.0",
|
|
51
51
|
"@types/chai-subset": "^1.3.3",
|
|
52
|
+
"chai": "^4.3.4",
|
|
52
53
|
"local-pkg": "^0.4.0",
|
|
53
54
|
"tinypool": "^0.0.3",
|
|
54
|
-
"tinyspy": "^0.
|
|
55
|
+
"tinyspy": "^0.2.4"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@antfu/install-pkg": "^0.1.0",
|
|
@@ -63,7 +64,6 @@
|
|
|
63
64
|
"@types/prompts": "^2.4.0",
|
|
64
65
|
"c8": "^7.10.0",
|
|
65
66
|
"cac": "^6.7.12",
|
|
66
|
-
"chai": "^4.3.4",
|
|
67
67
|
"chai-subset": "^1.6.0",
|
|
68
68
|
"cli-truncate": "^3.1.0",
|
|
69
69
|
"diff": "^5.0.0",
|