vitest 0.0.113 → 0.0.117
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 +61 -33
- package/dist/cli.js +1112 -35
- package/dist/{constants-900abe4a.js → constants-080f26e8.js} +2 -2
- package/dist/{diff-9c43ab50.js → diff-80c47cfa.js} +1 -2
- package/dist/entry.js +68 -26
- package/dist/{global-75208c77.js → global-d95ee155.js} +8 -9
- package/dist/{index-09437c50.js → index-2b1f526f.js} +2 -2
- package/dist/{index-c3f2f9fe.js → index-33d800eb.js} +182 -111
- package/dist/{index-61c8686f.js → index-648e7ab2.js} +62 -62
- package/dist/index-6e709f57.js +781 -0
- package/dist/index-bf29f0e6.js +386 -0
- package/dist/{index-9f4b9905.js → index-ce49e384.js} +33 -800
- package/dist/index-e909c175.js +62 -0
- package/dist/index.d.ts +97 -35
- package/dist/index.js +6 -4
- package/dist/{jest-mock-a57b745c.js → jest-mock-4a754991.js} +1 -12
- package/dist/node.d.ts +87 -16
- package/dist/node.js +10 -9
- package/dist/rpc-8c7cc374.js +5 -0
- package/dist/setup-95b119ff.js +4318 -0
- package/dist/utils.js +2 -2
- package/dist/{vi-51946984.js → vi-39f06eb7.js} +30 -6
- package/dist/worker.js +25 -40
- package/package.json +7 -6
- package/vitest.mjs +1 -20
- package/dist/index-041e627e.js +0 -168
- package/dist/index-1488b423.js +0 -186
- package/dist/middleware-0ebc5238.js +0 -79
- package/dist/rpc-7de86f29.js +0 -10
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function createBirpc({
|
|
2
|
+
functions,
|
|
3
|
+
post,
|
|
4
|
+
on,
|
|
5
|
+
eventNames = [],
|
|
6
|
+
serialize = (i) => i,
|
|
7
|
+
deserialize = (i) => i
|
|
8
|
+
}) {
|
|
9
|
+
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
10
|
+
on(async (data) => {
|
|
11
|
+
const msg = deserialize(data);
|
|
12
|
+
if (msg.t === "q") {
|
|
13
|
+
const { m: method, a: args } = msg;
|
|
14
|
+
let result, error;
|
|
15
|
+
try {
|
|
16
|
+
result = await functions[method](...args);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
error = e;
|
|
19
|
+
}
|
|
20
|
+
if (msg.i)
|
|
21
|
+
post(serialize({ t: "s", i: msg.i, r: result, e: error }));
|
|
22
|
+
} else {
|
|
23
|
+
const { i: ack, r: result, e: error } = msg;
|
|
24
|
+
const promise = rpcPromiseMap.get(ack);
|
|
25
|
+
if (error)
|
|
26
|
+
promise?.reject(error);
|
|
27
|
+
else
|
|
28
|
+
promise?.resolve(result);
|
|
29
|
+
rpcPromiseMap.delete(ack);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return new Proxy({}, {
|
|
33
|
+
get(_, method) {
|
|
34
|
+
const sendEvent = (...args) => {
|
|
35
|
+
post(serialize({ m: method, a: args, t: "q" }));
|
|
36
|
+
};
|
|
37
|
+
if (eventNames.includes(method)) {
|
|
38
|
+
sendEvent.asEvent = sendEvent;
|
|
39
|
+
return sendEvent;
|
|
40
|
+
}
|
|
41
|
+
const sendCall = (...args) => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const id = nanoid();
|
|
44
|
+
rpcPromiseMap.set(id, { resolve, reject });
|
|
45
|
+
post(serialize({ m: method, a: args, i: id, t: "q" }));
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
sendCall.asEvent = sendEvent;
|
|
49
|
+
return sendCall;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
54
|
+
function nanoid(size = 21) {
|
|
55
|
+
let id = "";
|
|
56
|
+
let i = size;
|
|
57
|
+
while (i--)
|
|
58
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
59
|
+
return id;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { createBirpc as c };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Formatter } from 'picocolors/types';
|
|
2
2
|
import { ViteDevServer } from 'vite';
|
|
3
|
+
import { RawSourceMap } from 'source-map-js';
|
|
3
4
|
import { OptionsReceived } from 'pretty-format';
|
|
4
5
|
import { MessagePort } from 'worker_threads';
|
|
5
|
-
import { RawSourceMap } from 'source-map-js';
|
|
6
6
|
export { Spy, SpyFn } from 'tinyspy';
|
|
7
7
|
export { assert, default as chai, should } from 'chai';
|
|
8
8
|
|
|
@@ -181,7 +181,7 @@ declare class StateManager {
|
|
|
181
181
|
idMap: Record<string, Task>;
|
|
182
182
|
taskFileMap: WeakMap<Task, File>;
|
|
183
183
|
getFiles(keys?: string[]): File[];
|
|
184
|
-
collectFiles(files
|
|
184
|
+
collectFiles(files?: File[]): void;
|
|
185
185
|
updateId(task: Task): void;
|
|
186
186
|
updateTasks(packs: TaskResultPack[]): void;
|
|
187
187
|
}
|
|
@@ -194,14 +194,21 @@ declare class Vitest {
|
|
|
194
194
|
reporters: Reporter[];
|
|
195
195
|
console: Console;
|
|
196
196
|
pool: WorkerPool | undefined;
|
|
197
|
+
outputStream: NodeJS.WriteStream & {
|
|
198
|
+
fd: 1;
|
|
199
|
+
};
|
|
200
|
+
errorStream: NodeJS.WriteStream & {
|
|
201
|
+
fd: 2;
|
|
202
|
+
};
|
|
197
203
|
invalidates: Set<string>;
|
|
198
204
|
changedTests: Set<string>;
|
|
205
|
+
visitedFilesMap: Map<string, RawSourceMap>;
|
|
199
206
|
runningPromise?: Promise<void>;
|
|
200
207
|
isFirstRun: boolean;
|
|
201
208
|
restartsCount: number;
|
|
202
209
|
private _onRestartListeners;
|
|
203
210
|
constructor();
|
|
204
|
-
setServer(options: UserConfig, server: ViteDevServer): void
|
|
211
|
+
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
205
212
|
start(filters?: string[]): Promise<void>;
|
|
206
213
|
runFiles(files: string[]): Promise<void>;
|
|
207
214
|
log(...args: any[]): void;
|
|
@@ -219,18 +226,18 @@ declare class Vitest {
|
|
|
219
226
|
}
|
|
220
227
|
|
|
221
228
|
declare abstract class BaseReporter implements Reporter {
|
|
222
|
-
ctx: Vitest;
|
|
223
229
|
start: number;
|
|
224
230
|
end: number;
|
|
225
231
|
watchFilters?: string[];
|
|
226
232
|
isTTY: boolean;
|
|
227
|
-
|
|
233
|
+
ctx: Vitest;
|
|
234
|
+
onInit(ctx: Vitest): void;
|
|
228
235
|
relative(path: string): string;
|
|
229
236
|
onFinished(files?: File[]): Promise<void>;
|
|
230
|
-
onTaskUpdate(
|
|
237
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
231
238
|
isFirstWatchRun: boolean;
|
|
232
239
|
onWatcherStart(): Promise<void>;
|
|
233
|
-
onWatcherRerun(files: string[], trigger
|
|
240
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
234
241
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
235
242
|
onServerRestart(): void;
|
|
236
243
|
reportSummary(files: File[]): Promise<void>;
|
|
@@ -239,8 +246,9 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
239
246
|
|
|
240
247
|
interface ListRendererOptions {
|
|
241
248
|
renderSucceed?: boolean;
|
|
249
|
+
outputStream: NodeJS.WritableStream;
|
|
242
250
|
}
|
|
243
|
-
declare const createListRenderer: (_tasks: Task[], options
|
|
251
|
+
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
244
252
|
start(): any;
|
|
245
253
|
update(_tasks: Task[]): any;
|
|
246
254
|
stop(): Promise<any>;
|
|
@@ -250,26 +258,26 @@ declare const createListRenderer: (_tasks: Task[], options?: ListRendererOptions
|
|
|
250
258
|
declare class DefaultReporter extends BaseReporter {
|
|
251
259
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
252
260
|
rendererOptions: ListRendererOptions;
|
|
253
|
-
|
|
261
|
+
onCollected(): void;
|
|
254
262
|
onFinished(files?: File[]): Promise<void>;
|
|
255
263
|
onWatcherStart(): Promise<void>;
|
|
256
264
|
stopListRender(): Promise<void>;
|
|
257
|
-
onWatcherRerun(files: string[], trigger
|
|
265
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
258
266
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
259
267
|
}
|
|
260
268
|
|
|
261
269
|
declare class DotReporter extends BaseReporter {
|
|
262
270
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
263
|
-
|
|
271
|
+
onCollected(): void;
|
|
264
272
|
onFinished(files?: File[]): Promise<void>;
|
|
265
273
|
onWatcherStart(): Promise<void>;
|
|
266
274
|
stopListRender(): Promise<void>;
|
|
267
|
-
onWatcherRerun(files: string[], trigger
|
|
275
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
268
276
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
269
277
|
}
|
|
270
278
|
|
|
271
279
|
declare class VerboseReporter extends DefaultReporter {
|
|
272
|
-
constructor(
|
|
280
|
+
constructor();
|
|
273
281
|
}
|
|
274
282
|
|
|
275
283
|
declare const ReportersMap: {
|
|
@@ -279,6 +287,56 @@ declare const ReportersMap: {
|
|
|
279
287
|
};
|
|
280
288
|
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
281
289
|
|
|
290
|
+
declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
291
|
+
interface C8Options {
|
|
292
|
+
/**
|
|
293
|
+
* Enable coverage, pass `--coverage` to enable
|
|
294
|
+
*
|
|
295
|
+
* @default false
|
|
296
|
+
*/
|
|
297
|
+
enabled?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Directory to write coverage report to
|
|
300
|
+
*/
|
|
301
|
+
reportsDirectory?: string;
|
|
302
|
+
/**
|
|
303
|
+
* Clean coverage before running tests
|
|
304
|
+
*
|
|
305
|
+
* @default true
|
|
306
|
+
*/
|
|
307
|
+
clean?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Clean coverage report on watch rerun
|
|
310
|
+
*
|
|
311
|
+
* @default false
|
|
312
|
+
*/
|
|
313
|
+
cleanOnRerun?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Allow files from outside of your cwd.
|
|
316
|
+
*
|
|
317
|
+
* @default false
|
|
318
|
+
*/
|
|
319
|
+
allowExternal?: any;
|
|
320
|
+
/**
|
|
321
|
+
* Reporters
|
|
322
|
+
*
|
|
323
|
+
* @default 'text'
|
|
324
|
+
*/
|
|
325
|
+
reporter?: Arrayable<CoverageReporter>;
|
|
326
|
+
/**
|
|
327
|
+
* Exclude coverage under /node_modules/
|
|
328
|
+
*
|
|
329
|
+
* @default true
|
|
330
|
+
*/
|
|
331
|
+
excludeNodeModules?: boolean;
|
|
332
|
+
exclude?: string[];
|
|
333
|
+
include?: string[];
|
|
334
|
+
skipFull?: boolean;
|
|
335
|
+
}
|
|
336
|
+
interface ResolvedC8Options extends Required<C8Options> {
|
|
337
|
+
tempDirectory: string;
|
|
338
|
+
}
|
|
339
|
+
|
|
282
340
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
283
341
|
declare type Nullable<T> = T | null | undefined;
|
|
284
342
|
declare type Arrayable<T> = T | Array<T>;
|
|
@@ -381,11 +439,12 @@ interface RuntimeContext {
|
|
|
381
439
|
}
|
|
382
440
|
|
|
383
441
|
interface Reporter {
|
|
384
|
-
|
|
442
|
+
onInit?(ctx: Vitest): void;
|
|
443
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
385
444
|
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
386
|
-
onTaskUpdate?: (
|
|
445
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
387
446
|
onWatcherStart?: () => Awaitable<void>;
|
|
388
|
-
onWatcherRerun?: (files: string[], trigger
|
|
447
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
389
448
|
onServerRestart?: () => Awaitable<void>;
|
|
390
449
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
391
450
|
}
|
|
@@ -550,6 +609,16 @@ interface InlineConfig {
|
|
|
550
609
|
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
551
610
|
*/
|
|
552
611
|
watchIgnore?: (string | RegExp)[];
|
|
612
|
+
/**
|
|
613
|
+
* Isolate environment for each test file
|
|
614
|
+
*
|
|
615
|
+
* @default true
|
|
616
|
+
*/
|
|
617
|
+
isolate?: boolean;
|
|
618
|
+
/**
|
|
619
|
+
* Coverage options
|
|
620
|
+
*/
|
|
621
|
+
coverage?: C8Options;
|
|
553
622
|
/**
|
|
554
623
|
* Open Vitest UI
|
|
555
624
|
* @internal WIP
|
|
@@ -604,11 +673,12 @@ interface UserConfig extends InlineConfig {
|
|
|
604
673
|
*/
|
|
605
674
|
passWithNoTests?: boolean;
|
|
606
675
|
}
|
|
607
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'> {
|
|
676
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage'> {
|
|
608
677
|
config?: string;
|
|
609
678
|
filters?: string[];
|
|
610
679
|
depsInline: (string | RegExp)[];
|
|
611
680
|
depsExternal: (string | RegExp)[];
|
|
681
|
+
coverage: ResolvedC8Options;
|
|
612
682
|
snapshotOptions: SnapshotStateOptions;
|
|
613
683
|
}
|
|
614
684
|
|
|
@@ -618,23 +688,15 @@ interface WorkerContext {
|
|
|
618
688
|
files: string[];
|
|
619
689
|
invalidates?: string[];
|
|
620
690
|
}
|
|
621
|
-
interface
|
|
622
|
-
fetch:
|
|
623
|
-
getSourceMap:
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
onCollected:
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
declare type RpcCall = <T extends keyof RpcMap>(method: T, ...args: RpcMap[T][0]) => Promise<RpcMap[T][1]>;
|
|
632
|
-
declare type RpcSend = <T extends keyof RpcMap>(method: T, ...args: RpcMap[T][0]) => void;
|
|
633
|
-
declare type RpcPayload<T extends keyof RpcMap = keyof RpcMap> = {
|
|
634
|
-
id: string;
|
|
635
|
-
method: T;
|
|
636
|
-
args: RpcMap[T][0];
|
|
637
|
-
};
|
|
691
|
+
interface WorkerRPC {
|
|
692
|
+
fetch: (id: string) => Promise<string | undefined>;
|
|
693
|
+
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
694
|
+
onWorkerExit: (code?: number) => void;
|
|
695
|
+
onUserLog: (log: UserConsoleLog) => void;
|
|
696
|
+
onCollected: (files: File[]) => void;
|
|
697
|
+
onTaskUpdate: (pack: TaskResultPack[]) => void;
|
|
698
|
+
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
699
|
+
}
|
|
638
700
|
|
|
639
701
|
declare const suite: ChainableFunction<"concurrent" | "skip" | "only" | "todo", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
640
702
|
declare const test: TestCollector;
|
|
@@ -879,4 +941,4 @@ declare global {
|
|
|
879
941
|
}
|
|
880
942
|
}
|
|
881
943
|
|
|
882
|
-
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, ConstructorArgumentsOf, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig,
|
|
944
|
+
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, ConstructorArgumentsOf, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, it, spies, spyOn, suite, test, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
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-
|
|
3
|
-
export { f as fn, s as spies, a as spyOn } from './jest-mock-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-39f06eb7.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-2b1f526f.js';
|
|
3
|
+
export { f as fn, s as spies, a as spyOn } from './jest-mock-4a754991.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
|
-
import './index-
|
|
5
|
+
import './index-bf29f0e6.js';
|
|
6
|
+
import 'url';
|
|
6
7
|
import 'tty';
|
|
7
8
|
import 'local-pkg';
|
|
9
|
+
import 'path';
|
|
8
10
|
import './_commonjsHelpers-c9e3b764.js';
|
|
9
11
|
import 'tinyspy';
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { util } from 'chai';
|
|
2
2
|
import * as tinyspy from 'tinyspy';
|
|
3
3
|
|
|
4
|
-
let urlAlphabet =
|
|
5
|
-
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
6
|
-
let nanoid = (size = 21) => {
|
|
7
|
-
let id = '';
|
|
8
|
-
let i = size;
|
|
9
|
-
while (i--) {
|
|
10
|
-
id += urlAlphabet[(Math.random() * 64) | 0];
|
|
11
|
-
}
|
|
12
|
-
return id
|
|
13
|
-
};
|
|
14
|
-
|
|
15
4
|
const spies = /* @__PURE__ */ new Set();
|
|
16
5
|
function spyOn(obj, method, accessType) {
|
|
17
6
|
const dictionary = {
|
|
@@ -98,4 +87,4 @@ function fn(implementation) {
|
|
|
98
87
|
}) }, "fn"));
|
|
99
88
|
}
|
|
100
89
|
|
|
101
|
-
export { spyOn as a, fn as f,
|
|
90
|
+
export { spyOn as a, fn as f, spies as s };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { ViteDevServer, UserConfig as UserConfig$1 } from 'vite';
|
|
2
|
+
import { RawSourceMap } from 'source-map-js';
|
|
2
3
|
import { OptionsReceived } from 'pretty-format';
|
|
3
4
|
|
|
4
5
|
declare abstract class BaseReporter implements Reporter {
|
|
5
|
-
ctx: Vitest;
|
|
6
6
|
start: number;
|
|
7
7
|
end: number;
|
|
8
8
|
watchFilters?: string[];
|
|
9
9
|
isTTY: boolean;
|
|
10
|
-
|
|
10
|
+
ctx: Vitest;
|
|
11
|
+
onInit(ctx: Vitest): void;
|
|
11
12
|
relative(path: string): string;
|
|
12
13
|
onFinished(files?: File[]): Promise<void>;
|
|
13
|
-
onTaskUpdate(
|
|
14
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
14
15
|
isFirstWatchRun: boolean;
|
|
15
16
|
onWatcherStart(): Promise<void>;
|
|
16
|
-
onWatcherRerun(files: string[], trigger
|
|
17
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
17
18
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
18
19
|
onServerRestart(): void;
|
|
19
20
|
reportSummary(files: File[]): Promise<void>;
|
|
@@ -22,8 +23,9 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
22
23
|
|
|
23
24
|
interface ListRendererOptions {
|
|
24
25
|
renderSucceed?: boolean;
|
|
26
|
+
outputStream: NodeJS.WritableStream;
|
|
25
27
|
}
|
|
26
|
-
declare const createListRenderer: (_tasks: Task[], options
|
|
28
|
+
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
27
29
|
start(): any;
|
|
28
30
|
update(_tasks: Task[]): any;
|
|
29
31
|
stop(): Promise<any>;
|
|
@@ -33,26 +35,26 @@ declare const createListRenderer: (_tasks: Task[], options?: ListRendererOptions
|
|
|
33
35
|
declare class DefaultReporter extends BaseReporter {
|
|
34
36
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
35
37
|
rendererOptions: ListRendererOptions;
|
|
36
|
-
|
|
38
|
+
onCollected(): void;
|
|
37
39
|
onFinished(files?: File[]): Promise<void>;
|
|
38
40
|
onWatcherStart(): Promise<void>;
|
|
39
41
|
stopListRender(): Promise<void>;
|
|
40
|
-
onWatcherRerun(files: string[], trigger
|
|
42
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
41
43
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
declare class DotReporter extends BaseReporter {
|
|
45
47
|
renderer?: ReturnType<typeof createListRenderer>;
|
|
46
|
-
|
|
48
|
+
onCollected(): void;
|
|
47
49
|
onFinished(files?: File[]): Promise<void>;
|
|
48
50
|
onWatcherStart(): Promise<void>;
|
|
49
51
|
stopListRender(): Promise<void>;
|
|
50
|
-
onWatcherRerun(files: string[], trigger
|
|
52
|
+
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
51
53
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
declare class VerboseReporter extends DefaultReporter {
|
|
55
|
-
constructor(
|
|
57
|
+
constructor();
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
declare const ReportersMap: {
|
|
@@ -62,6 +64,56 @@ declare const ReportersMap: {
|
|
|
62
64
|
};
|
|
63
65
|
declare type BuiltinReporters = keyof typeof ReportersMap;
|
|
64
66
|
|
|
67
|
+
declare type CoverageReporter = 'clover' | 'cobertura' | 'html-spa' | 'html' | 'json-summary' | 'json' | 'lcov' | 'lcovonly' | 'none' | 'teamcity' | 'text-lcov' | 'text-summary' | 'text';
|
|
68
|
+
interface C8Options {
|
|
69
|
+
/**
|
|
70
|
+
* Enable coverage, pass `--coverage` to enable
|
|
71
|
+
*
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Directory to write coverage report to
|
|
77
|
+
*/
|
|
78
|
+
reportsDirectory?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Clean coverage before running tests
|
|
81
|
+
*
|
|
82
|
+
* @default true
|
|
83
|
+
*/
|
|
84
|
+
clean?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Clean coverage report on watch rerun
|
|
87
|
+
*
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
cleanOnRerun?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Allow files from outside of your cwd.
|
|
93
|
+
*
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
allowExternal?: any;
|
|
97
|
+
/**
|
|
98
|
+
* Reporters
|
|
99
|
+
*
|
|
100
|
+
* @default 'text'
|
|
101
|
+
*/
|
|
102
|
+
reporter?: Arrayable<CoverageReporter>;
|
|
103
|
+
/**
|
|
104
|
+
* Exclude coverage under /node_modules/
|
|
105
|
+
*
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
excludeNodeModules?: boolean;
|
|
109
|
+
exclude?: string[];
|
|
110
|
+
include?: string[];
|
|
111
|
+
skipFull?: boolean;
|
|
112
|
+
}
|
|
113
|
+
interface ResolvedC8Options extends Required<C8Options> {
|
|
114
|
+
tempDirectory: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
65
117
|
declare type Awaitable<T> = T | PromiseLike<T>;
|
|
66
118
|
declare type Arrayable<T> = T | Array<T>;
|
|
67
119
|
declare type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
@@ -106,11 +158,12 @@ interface Test extends TaskBase {
|
|
|
106
158
|
declare type Task = Test | Suite | File;
|
|
107
159
|
|
|
108
160
|
interface Reporter {
|
|
109
|
-
|
|
161
|
+
onInit?(ctx: Vitest): void;
|
|
162
|
+
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
110
163
|
onFinished?: (files?: File[]) => Awaitable<void>;
|
|
111
|
-
onTaskUpdate?: (
|
|
164
|
+
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
112
165
|
onWatcherStart?: () => Awaitable<void>;
|
|
113
|
-
onWatcherRerun?: (files: string[], trigger
|
|
166
|
+
onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
|
|
114
167
|
onServerRestart?: () => Awaitable<void>;
|
|
115
168
|
onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
|
|
116
169
|
}
|
|
@@ -266,6 +319,16 @@ interface InlineConfig {
|
|
|
266
319
|
* @default ['**\/node_modules\/**', '**\/dist/**']
|
|
267
320
|
*/
|
|
268
321
|
watchIgnore?: (string | RegExp)[];
|
|
322
|
+
/**
|
|
323
|
+
* Isolate environment for each test file
|
|
324
|
+
*
|
|
325
|
+
* @default true
|
|
326
|
+
*/
|
|
327
|
+
isolate?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Coverage options
|
|
330
|
+
*/
|
|
331
|
+
coverage?: C8Options;
|
|
269
332
|
/**
|
|
270
333
|
* Open Vitest UI
|
|
271
334
|
* @internal WIP
|
|
@@ -320,11 +383,12 @@ interface UserConfig extends InlineConfig {
|
|
|
320
383
|
*/
|
|
321
384
|
passWithNoTests?: boolean;
|
|
322
385
|
}
|
|
323
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'> {
|
|
386
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage'> {
|
|
324
387
|
config?: string;
|
|
325
388
|
filters?: string[];
|
|
326
389
|
depsInline: (string | RegExp)[];
|
|
327
390
|
depsExternal: (string | RegExp)[];
|
|
391
|
+
coverage: ResolvedC8Options;
|
|
328
392
|
snapshotOptions: SnapshotStateOptions;
|
|
329
393
|
}
|
|
330
394
|
|
|
@@ -348,7 +412,7 @@ declare class StateManager {
|
|
|
348
412
|
idMap: Record<string, Task>;
|
|
349
413
|
taskFileMap: WeakMap<Task, File>;
|
|
350
414
|
getFiles(keys?: string[]): File[];
|
|
351
|
-
collectFiles(files
|
|
415
|
+
collectFiles(files?: File[]): void;
|
|
352
416
|
updateId(task: Task): void;
|
|
353
417
|
updateTasks(packs: TaskResultPack[]): void;
|
|
354
418
|
}
|
|
@@ -361,14 +425,21 @@ declare class Vitest {
|
|
|
361
425
|
reporters: Reporter[];
|
|
362
426
|
console: Console;
|
|
363
427
|
pool: WorkerPool | undefined;
|
|
428
|
+
outputStream: NodeJS.WriteStream & {
|
|
429
|
+
fd: 1;
|
|
430
|
+
};
|
|
431
|
+
errorStream: NodeJS.WriteStream & {
|
|
432
|
+
fd: 2;
|
|
433
|
+
};
|
|
364
434
|
invalidates: Set<string>;
|
|
365
435
|
changedTests: Set<string>;
|
|
436
|
+
visitedFilesMap: Map<string, RawSourceMap>;
|
|
366
437
|
runningPromise?: Promise<void>;
|
|
367
438
|
isFirstRun: boolean;
|
|
368
439
|
restartsCount: number;
|
|
369
440
|
private _onRestartListeners;
|
|
370
441
|
constructor();
|
|
371
|
-
setServer(options: UserConfig, server: ViteDevServer): void
|
|
442
|
+
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
372
443
|
start(filters?: string[]): Promise<void>;
|
|
373
444
|
runFiles(files: string[]): Promise<void>;
|
|
374
445
|
log(...args: any[]): void;
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import './index-
|
|
1
|
+
export { c as createVitest } from './index-33d800eb.js';
|
|
2
|
+
import './index-bf29f0e6.js';
|
|
3
|
+
import 'url';
|
|
4
|
+
import 'tty';
|
|
5
|
+
import 'local-pkg';
|
|
3
6
|
import 'path';
|
|
4
7
|
import 'vite';
|
|
5
8
|
import 'process';
|
|
@@ -8,16 +11,14 @@ import 'os';
|
|
|
8
11
|
import 'util';
|
|
9
12
|
import 'stream';
|
|
10
13
|
import 'events';
|
|
11
|
-
import './
|
|
12
|
-
import 'tty';
|
|
13
|
-
import 'local-pkg';
|
|
14
|
-
import './constants-900abe4a.js';
|
|
15
|
-
import 'url';
|
|
14
|
+
import './constants-080f26e8.js';
|
|
16
15
|
import './magic-string.es-94000aea.js';
|
|
17
16
|
import 'perf_hooks';
|
|
18
|
-
import './diff-
|
|
19
|
-
import './index-
|
|
17
|
+
import './diff-80c47cfa.js';
|
|
18
|
+
import './index-648e7ab2.js';
|
|
20
19
|
import './_commonjsHelpers-c9e3b764.js';
|
|
21
20
|
import 'assert';
|
|
21
|
+
import 'module';
|
|
22
22
|
import 'worker_threads';
|
|
23
23
|
import 'tinypool';
|
|
24
|
+
import './index-e909c175.js';
|