vitest 0.0.110 → 0.0.111
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/cli.js +6 -6
- package/dist/{constants-e762cbc5.js → constants-2b0310b7.js} +1 -1
- package/dist/{diff-46ee5d7d.js → diff-66d6bb83.js} +2 -2
- package/dist/entry.js +4 -4
- package/dist/{global-b8ab5632.js → global-201fd559.js} +4 -4
- package/dist/{index-a90f376d.js → index-2bb9fd4d.js} +1 -1
- package/dist/{index-b183bb20.js → index-8ab26d25.js} +1752 -1617
- package/dist/index.d.ts +119 -15
- package/dist/index.js +3 -3
- package/dist/{middleware-093a3bde.js → middleware-2028dfa0.js} +2 -2
- package/dist/node.d.ts +62 -1
- package/dist/node.js +4 -4
- package/dist/{utils-d97bd6d9.js → utils-cb6b1266.js} +5 -2
- package/dist/utils.js +1 -1
- package/dist/{vi-aedc8539.js → vi-cb9e4e4e.js} +1 -1
- package/dist/worker.js +5 -2
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Formatter } from 'picocolors/types';
|
|
2
|
+
import { ViteDevServer } from 'vite';
|
|
2
3
|
import { OptionsReceived } from 'pretty-format';
|
|
3
4
|
import { MessagePort } from 'worker_threads';
|
|
4
5
|
export { Spy, SpyFn } from 'tinyspy';
|
|
@@ -159,6 +160,123 @@ declare class StringMatching extends AsymmetricMatcher<RegExp> {
|
|
|
159
160
|
getExpectedType(): string;
|
|
160
161
|
}
|
|
161
162
|
|
|
163
|
+
declare class SnapshotManager {
|
|
164
|
+
config: ResolvedConfig;
|
|
165
|
+
summary: SnapshotSummary;
|
|
166
|
+
constructor(config: ResolvedConfig);
|
|
167
|
+
clear(): void;
|
|
168
|
+
add(result: SnapshotResult): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
|
|
172
|
+
interface WorkerPool {
|
|
173
|
+
runTests: RunWithFiles;
|
|
174
|
+
collectTests: RunWithFiles;
|
|
175
|
+
close: () => Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class StateManager {
|
|
179
|
+
filesMap: Record<string, File>;
|
|
180
|
+
idMap: Record<string, Task>;
|
|
181
|
+
taskFileMap: WeakMap<Task, File>;
|
|
182
|
+
getFiles(keys?: string[]): File[];
|
|
183
|
+
collectFiles(files: File[]): void;
|
|
184
|
+
updateId(task: Task): void;
|
|
185
|
+
updateTasks(packs: TaskResultPack[]): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare class Vitest {
|
|
189
|
+
config: ResolvedConfig;
|
|
190
|
+
server: ViteDevServer;
|
|
191
|
+
state: StateManager;
|
|
192
|
+
snapshot: SnapshotManager;
|
|
193
|
+
reporters: Reporter[];
|
|
194
|
+
console: Console;
|
|
195
|
+
pool: WorkerPool | undefined;
|
|
196
|
+
invalidates: Set<string>;
|
|
197
|
+
changedTests: Set<string>;
|
|
198
|
+
runningPromise?: Promise<void>;
|
|
199
|
+
isFirstRun: boolean;
|
|
200
|
+
restartsCount: number;
|
|
201
|
+
private _onRestartListeners;
|
|
202
|
+
constructor();
|
|
203
|
+
setServer(options: UserConfig, server: ViteDevServer): void;
|
|
204
|
+
start(filters?: string[]): Promise<void>;
|
|
205
|
+
runFiles(files: string[]): Promise<void>;
|
|
206
|
+
log(...args: any[]): void;
|
|
207
|
+
error(...args: any[]): void;
|
|
208
|
+
private _rerunTimer;
|
|
209
|
+
private scheduleRerun;
|
|
210
|
+
private unregisterWatcher;
|
|
211
|
+
private registerWatcher;
|
|
212
|
+
private handleFileChanged;
|
|
213
|
+
close(): Promise<void>;
|
|
214
|
+
report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
|
|
215
|
+
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
216
|
+
isTargetFile(id: string): boolean;
|
|
217
|
+
onServerRestarted(fn: () => void): void;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare abstract class BaseReporter implements Reporter {
|
|
221
|
+
ctx: Vitest;
|
|
222
|
+
start: number;
|
|
223
|
+
end: number;
|
|
224
|
+
watchFilters?: string[];
|
|
225
|
+
isTTY: boolean;
|
|
226
|
+
constructor(ctx: Vitest);
|
|
227
|
+
relative(path: string): string;
|
|
228
|
+
onFinished(files?: File[]): Promise<void>;
|
|
229
|
+
onTaskUpdate(pack: TaskResultPack): void;
|
|
230
|
+
isFirstWatchRun: boolean;
|
|
231
|
+
onWatcherStart(): Promise<void>;
|
|
232
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
233
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
234
|
+
onServerRestart(): void;
|
|
235
|
+
reportSummary(files: File[]): Promise<void>;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
interface ListRendererOptions {
|
|
239
|
+
renderSucceed?: boolean;
|
|
240
|
+
}
|
|
241
|
+
declare const createListRenderer: (_tasks: Task[], options?: ListRendererOptions) => {
|
|
242
|
+
start(): any;
|
|
243
|
+
update(_tasks: Task[]): any;
|
|
244
|
+
stop(): Promise<any>;
|
|
245
|
+
clear(): void;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
declare class DefaultReporter extends BaseReporter {
|
|
249
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
250
|
+
rendererOptions: ListRendererOptions;
|
|
251
|
+
onStart(): void;
|
|
252
|
+
onFinished(files?: File[]): Promise<void>;
|
|
253
|
+
onWatcherStart(): Promise<void>;
|
|
254
|
+
stopListRender(): Promise<void>;
|
|
255
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
256
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
declare class DotReporter extends BaseReporter {
|
|
260
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
261
|
+
onStart(): void;
|
|
262
|
+
onFinished(files?: File[]): Promise<void>;
|
|
263
|
+
onWatcherStart(): Promise<void>;
|
|
264
|
+
stopListRender(): Promise<void>;
|
|
265
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
266
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
270
|
+
constructor(ctx: Vitest);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
declare const ReportersMap: {
|
|
274
|
+
default: typeof DefaultReporter;
|
|
275
|
+
verbose: typeof VerboseReporter;
|
|
276
|
+
dot: typeof DotReporter;
|
|
277
|
+
};
|
|
278
|
+
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
279
|
+
|
|
162
280
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
163
281
|
declare type Nullable<T> = T | null | undefined;
|
|
164
282
|
declare type Arrayable<T> = T | Array<T>;
|
|
@@ -372,7 +490,7 @@ interface InlineConfig {
|
|
|
372
490
|
/**
|
|
373
491
|
* Custom reporter for output
|
|
374
492
|
*/
|
|
375
|
-
reporters?:
|
|
493
|
+
reporters?: Arrayable<BuiltinReporters | Reporter>;
|
|
376
494
|
/**
|
|
377
495
|
* Enable multi-threading
|
|
378
496
|
*
|
|
@@ -509,20 +627,6 @@ declare const suite: ChainableFunction<"skip" | "only" | "todo" | "concurrent",
|
|
|
509
627
|
declare const test: TestCollector;
|
|
510
628
|
declare const describe: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
511
629
|
declare const it: TestCollector;
|
|
512
|
-
declare global {
|
|
513
|
-
namespace NodeJS {
|
|
514
|
-
interface Process {
|
|
515
|
-
__vitest_worker__: {
|
|
516
|
-
config: ResolvedConfig;
|
|
517
|
-
rpc: RpcCall;
|
|
518
|
-
send: RpcSend;
|
|
519
|
-
current?: Test;
|
|
520
|
-
filepath?: string;
|
|
521
|
-
moduleCache: Map<string, ModuleCache>;
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
630
|
|
|
527
631
|
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
|
|
528
632
|
declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undefined) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-cb9e4e4e.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-2bb9fd4d.js';
|
|
3
3
|
export { f as fn, s as spies, a as spyOn } from './jest-mock-a57b745c.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
|
-
import './utils-
|
|
5
|
+
import './utils-cb6b1266.js';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
8
|
import 'path';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,7 +1,68 @@
|
|
|
1
1
|
import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
2
|
import { OptionsReceived } from 'pretty-format';
|
|
3
3
|
|
|
4
|
+
declare abstract class BaseReporter implements Reporter {
|
|
5
|
+
ctx: Vitest;
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
watchFilters?: string[];
|
|
9
|
+
isTTY: boolean;
|
|
10
|
+
constructor(ctx: Vitest);
|
|
11
|
+
relative(path: string): string;
|
|
12
|
+
onFinished(files?: File[]): Promise<void>;
|
|
13
|
+
onTaskUpdate(pack: TaskResultPack): void;
|
|
14
|
+
isFirstWatchRun: boolean;
|
|
15
|
+
onWatcherStart(): Promise<void>;
|
|
16
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
17
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
18
|
+
onServerRestart(): void;
|
|
19
|
+
reportSummary(files: File[]): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ListRendererOptions {
|
|
23
|
+
renderSucceed?: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare const createListRenderer: (_tasks: Task[], options?: ListRendererOptions) => {
|
|
26
|
+
start(): any;
|
|
27
|
+
update(_tasks: Task[]): any;
|
|
28
|
+
stop(): Promise<any>;
|
|
29
|
+
clear(): void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare class DefaultReporter extends BaseReporter {
|
|
33
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
34
|
+
rendererOptions: ListRendererOptions;
|
|
35
|
+
onStart(): void;
|
|
36
|
+
onFinished(files?: File[]): Promise<void>;
|
|
37
|
+
onWatcherStart(): Promise<void>;
|
|
38
|
+
stopListRender(): Promise<void>;
|
|
39
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
40
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare class DotReporter extends BaseReporter {
|
|
44
|
+
renderer?: ReturnType<typeof createListRenderer>;
|
|
45
|
+
onStart(): void;
|
|
46
|
+
onFinished(files?: File[]): Promise<void>;
|
|
47
|
+
onWatcherStart(): Promise<void>;
|
|
48
|
+
stopListRender(): Promise<void>;
|
|
49
|
+
onWatcherRerun(files: string[], trigger: string): Promise<void>;
|
|
50
|
+
onUserConsoleLog(log: UserConsoleLog): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare class VerboseReporter extends DefaultReporter {
|
|
54
|
+
constructor(ctx: Vitest);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare const ReportersMap: {
|
|
58
|
+
default: typeof DefaultReporter;
|
|
59
|
+
verbose: typeof VerboseReporter;
|
|
60
|
+
dot: typeof DotReporter;
|
|
61
|
+
};
|
|
62
|
+
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
63
|
+
|
|
4
64
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
65
|
+
declare type Arrayable<T> = T | Array<T>;
|
|
5
66
|
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
6
67
|
interface UserConsoleLog {
|
|
7
68
|
content: string;
|
|
@@ -156,7 +217,7 @@ interface InlineConfig {
|
|
|
156
217
|
/**
|
|
157
218
|
* Custom reporter for output
|
|
158
219
|
*/
|
|
159
|
-
reporters?:
|
|
220
|
+
reporters?: Arrayable<BuiltinReporters | Reporter>;
|
|
160
221
|
/**
|
|
161
222
|
* Enable multi-threading
|
|
162
223
|
*
|
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-8ab26d25.js';
|
|
2
|
+
import './utils-cb6b1266.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-2b0310b7.js';
|
|
14
14
|
import 'url';
|
|
15
15
|
import 'perf_hooks';
|
|
16
|
-
import './diff-
|
|
16
|
+
import './diff-66d6bb83.js';
|
|
17
17
|
import './index-61c8686f.js';
|
|
18
18
|
import './_commonjsHelpers-c9e3b764.js';
|
|
19
19
|
import 'assert';
|
|
@@ -299,7 +299,7 @@ function interpretOnlyMode(tasks) {
|
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
301
|
function getTests(suite) {
|
|
302
|
-
return toArray(suite).flatMap((s) => s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
|
|
302
|
+
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
|
|
303
303
|
}
|
|
304
304
|
function getTasks(tasks) {
|
|
305
305
|
return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
|
|
@@ -326,6 +326,9 @@ function getNames(task) {
|
|
|
326
326
|
}
|
|
327
327
|
return names;
|
|
328
328
|
}
|
|
329
|
+
function getFullName(task) {
|
|
330
|
+
return getNames(task).join(c.dim(" > "));
|
|
331
|
+
}
|
|
329
332
|
async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
|
|
330
333
|
if (isPackageExists(dependency))
|
|
331
334
|
return true;
|
|
@@ -346,4 +349,4 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
|
|
|
346
349
|
return false;
|
|
347
350
|
}
|
|
348
351
|
|
|
349
|
-
export { getTests as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f,
|
|
352
|
+
export { getTests as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, resolve as h, isAbsolute as i, hasFailed as j, notNullish as k, index as l, mergeSlashes as m, noop as n, getNames as o, interpretOnlyMode as p, partitionSuiteChildren as q, relative as r, slash as s, toArray as t, hasTests as u, getTasks as v };
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as ensurePackageInstalled, g as getNames, f as getSuites,
|
|
1
|
+
export { e as ensurePackageInstalled, g as getFullName, o as getNames, f as getSuites, v as getTasks, a as getTests, j as hasFailed, u as hasTests, p as interpretOnlyMode, m as mergeSlashes, n as noop, k as notNullish, q as partitionSuiteChildren, h as resolvePath, s as slash, t as toArray } from './utils-cb6b1266.js';
|
|
2
2
|
import 'local-pkg';
|
|
3
3
|
import 'tty';
|
|
4
4
|
import 'path';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as nanoid, a as spyOn, f as fn, s as spies } from './jest-mock-a57b745c.js';
|
|
2
|
-
import { n as noop } from './utils-
|
|
2
|
+
import { n as noop } from './utils-cb6b1266.js';
|
|
3
3
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
package/dist/worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { h as resolve, d as dirname$2, b as basename$2, m as mergeSlashes, s as slash } from './utils-
|
|
1
|
+
import { h as resolve, d as dirname$2, b as basename$2, m as mergeSlashes, s as slash } from './utils-cb6b1266.js';
|
|
2
2
|
import { a as spyOn, s as spies, n as nanoid } from './jest-mock-a57b745c.js';
|
|
3
|
-
import { c as distDir } from './constants-
|
|
3
|
+
import { c as distDir } from './constants-2b0310b7.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';
|
|
@@ -9590,10 +9590,13 @@ async function startViteNode(ctx) {
|
|
|
9590
9590
|
return _viteNode;
|
|
9591
9591
|
}
|
|
9592
9592
|
function init(ctx) {
|
|
9593
|
+
if (process.__vitest_worker__ && ctx.config.threads)
|
|
9594
|
+
throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${process.__vitest_worker__.ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
|
|
9593
9595
|
process.stdout.write("\0");
|
|
9594
9596
|
const { config, port } = ctx;
|
|
9595
9597
|
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
9596
9598
|
process.__vitest_worker__ = {
|
|
9599
|
+
ctx,
|
|
9597
9600
|
moduleCache,
|
|
9598
9601
|
config,
|
|
9599
9602
|
rpc: (method, ...args) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.111",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -51,16 +51,16 @@
|
|
|
51
51
|
"@types/chai-subset": "^1.3.3",
|
|
52
52
|
"chai": "^4.3.4",
|
|
53
53
|
"local-pkg": "^0.4.0",
|
|
54
|
-
"tinypool": "^0.0.
|
|
55
|
-
"tinyspy": "^0.2.
|
|
54
|
+
"tinypool": "^0.0.6",
|
|
55
|
+
"tinyspy": "^0.2.6"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@antfu/install-pkg": "^0.1.0",
|
|
59
|
-
"@types/diff": "^5.0.
|
|
59
|
+
"@types/diff": "^5.0.2",
|
|
60
60
|
"@types/jsdom": "^16.2.14",
|
|
61
61
|
"@types/micromatch": "^4.0.2",
|
|
62
62
|
"@types/natural-compare": "^1.4.1",
|
|
63
|
-
"@types/node": "^17.0.
|
|
63
|
+
"@types/node": "^17.0.4",
|
|
64
64
|
"@types/prompts": "^2.4.0",
|
|
65
65
|
"c8": "^7.10.0",
|
|
66
66
|
"cac": "^6.7.12",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"pkg-types": "^0.3.2",
|
|
85
85
|
"pretty-format": "^27.4.2",
|
|
86
86
|
"prompts": "^2.4.2",
|
|
87
|
-
"rollup": "^2.
|
|
87
|
+
"rollup": "^2.62.0",
|
|
88
88
|
"source-map-js": "^1.0.1",
|
|
89
89
|
"strip-ansi": "^7.0.1",
|
|
90
90
|
"typescript": "^4.5.4"
|