vitest 0.17.1 → 0.19.0
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 +6 -6
- package/dist/browser.d.ts +1850 -0
- package/dist/browser.mjs +20 -0
- package/dist/{chunk-api-setup.c728e251.mjs → chunk-api-setup.0cf2c96a.mjs} +37 -11
- package/dist/{chunk-constants.27550afb.mjs → chunk-constants.38b43a44.mjs} +3 -3
- package/dist/{chunk-env-node.aa51c4cc.mjs → chunk-defaults.408a0cfe.mjs} +457 -455
- package/dist/{chunk-install-pkg.6f5930c3.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
- package/dist/chunk-integrations-globals.803277be.mjs +24 -0
- package/dist/chunk-node-git.9058b82a.mjs +1139 -0
- package/dist/chunk-runtime-chain.1e1aabb3.mjs +2025 -0
- package/dist/{vendor-entry.1ad8a08d.mjs → chunk-runtime-error.d82dd2cf.mjs} +167 -183
- package/dist/{chunk-runtime-chain.6d23d202.mjs → chunk-runtime-hooks.db398170.mjs} +33 -2012
- package/dist/{chunk-runtime-mocker.34b9d585.mjs → chunk-runtime-mocker.dfdfd57b.mjs} +70 -22
- package/dist/{chunk-runtime-rpc.d986adb9.mjs → chunk-runtime-rpc.45d8ee19.mjs} +1 -1
- package/dist/{chunk-utils-global.4828c2e2.mjs → chunk-utils-global.2aa95025.mjs} +14 -9
- package/dist/{chunk-utils-source-map.a9047343.mjs → chunk-utils-source-map.8b066ce2.mjs} +2 -2
- package/dist/{chunk-vite-node-externalize.0fc8ed68.mjs → chunk-vite-node-externalize.a2813ad7.mjs} +1202 -2178
- package/dist/chunk-vite-node-utils.ad73f2ab.mjs +1433 -0
- package/dist/cli.mjs +11 -13
- package/dist/config.cjs +4 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.mjs +4 -1
- package/dist/entry.mjs +54 -10
- package/dist/index.d.ts +126 -58
- package/dist/index.mjs +12 -9
- package/dist/node.d.ts +109 -58
- package/dist/node.mjs +12 -14
- package/dist/spy.mjs +102 -2
- package/dist/suite.mjs +13 -0
- package/dist/vendor-index.61438b77.mjs +335 -0
- package/dist/{vendor-index.a2a385d8.mjs → vendor-index.62ce5c33.mjs} +6 -338
- package/dist/{vendor-index.98e769c1.mjs → vendor-index.de788b6a.mjs} +7 -7
- package/dist/worker.mjs +6 -6
- package/package.json +20 -12
- package/dist/chunk-integrations-globals.3df36e26.mjs +0 -26
- package/dist/chunk-integrations-spy.674b628e.mjs +0 -102
- package/dist/chunk-vite-node-utils.0f776286.mjs +0 -9195
package/dist/cli.mjs
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { p as picocolors } from './chunk-utils-global.
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
2
|
+
import { p as picocolors } from './chunk-utils-global.2aa95025.mjs';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.a2813ad7.mjs';
|
|
4
|
+
import 'path';
|
|
4
5
|
import 'tty';
|
|
5
6
|
import 'local-pkg';
|
|
6
|
-
import '
|
|
7
|
-
import './chunk-env-node.aa51c4cc.mjs';
|
|
7
|
+
import './chunk-defaults.408a0cfe.mjs';
|
|
8
8
|
import 'fs';
|
|
9
9
|
import 'module';
|
|
10
10
|
import 'url';
|
|
11
11
|
import 'vite';
|
|
12
12
|
import 'process';
|
|
13
|
-
import './chunk-constants.
|
|
14
|
-
import 'readline';
|
|
13
|
+
import './chunk-constants.38b43a44.mjs';
|
|
15
14
|
import 'os';
|
|
16
15
|
import 'util';
|
|
17
16
|
import 'stream';
|
|
18
17
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
19
|
-
import './chunk-vite-node-utils.
|
|
18
|
+
import './chunk-vite-node-utils.ad73f2ab.mjs';
|
|
20
19
|
import 'vm';
|
|
21
20
|
import 'assert';
|
|
22
21
|
import 'debug';
|
|
23
22
|
import 'worker_threads';
|
|
24
23
|
import 'tinypool';
|
|
25
24
|
import 'perf_hooks';
|
|
26
|
-
import './chunk-utils-source-map.
|
|
27
|
-
import './vendor-index.a2a385d8.mjs';
|
|
28
|
-
import 'child_process';
|
|
29
|
-
import 'buffer';
|
|
25
|
+
import './chunk-utils-source-map.8b066ce2.mjs';
|
|
30
26
|
import 'crypto';
|
|
27
|
+
import './vendor-index.61438b77.mjs';
|
|
31
28
|
import './chunk-magic-string.efe26975.mjs';
|
|
32
|
-
import '
|
|
29
|
+
import 'readline';
|
|
30
|
+
import './vendor-index.de788b6a.mjs';
|
|
33
31
|
|
|
34
32
|
function toArr(any) {
|
|
35
33
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
@@ -645,7 +643,7 @@ class CAC extends EventEmitter {
|
|
|
645
643
|
const cac = (name = "") => new CAC(name);
|
|
646
644
|
|
|
647
645
|
const cli = cac("vitest");
|
|
648
|
-
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of mutliple reporters").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").help();
|
|
646
|
+
cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of mutliple reporters").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--browser", "run tests in browser").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").help();
|
|
649
647
|
cli.command("run [...filters]").action(run);
|
|
650
648
|
cli.command("related [...filters]").action(runRelated);
|
|
651
649
|
cli.command("watch [...filters]").action(start);
|
package/dist/config.cjs
CHANGED
|
@@ -6,14 +6,16 @@ const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
|
6
6
|
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
|
|
7
7
|
const defaultCoverageExcludes = [
|
|
8
8
|
"coverage/**",
|
|
9
|
+
"dist/**",
|
|
9
10
|
"packages/*/test{,s}/**",
|
|
10
11
|
"**/*.d.ts",
|
|
11
12
|
"cypress/**",
|
|
12
13
|
"test{,s}/**",
|
|
13
14
|
"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
|
|
14
15
|
"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
|
|
16
|
+
"**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
|
|
15
17
|
"**/__tests__/**",
|
|
16
|
-
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
|
|
18
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
|
|
17
19
|
"**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
|
|
18
20
|
];
|
|
19
21
|
const coverageConfigDefaults = {
|
|
@@ -53,6 +55,7 @@ const config = {
|
|
|
53
55
|
exclude: defaultExclude,
|
|
54
56
|
testTimeout: 5e3,
|
|
55
57
|
hookTimeout: 1e4,
|
|
58
|
+
teardownTimeout: 1e3,
|
|
56
59
|
isolate: true,
|
|
57
60
|
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
58
61
|
forceRerunTriggers: [
|
package/dist/config.d.ts
CHANGED
package/dist/config.mjs
CHANGED
|
@@ -2,14 +2,16 @@ const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
|
2
2
|
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
|
|
3
3
|
const defaultCoverageExcludes = [
|
|
4
4
|
"coverage/**",
|
|
5
|
+
"dist/**",
|
|
5
6
|
"packages/*/test{,s}/**",
|
|
6
7
|
"**/*.d.ts",
|
|
7
8
|
"cypress/**",
|
|
8
9
|
"test{,s}/**",
|
|
9
10
|
"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
|
|
10
11
|
"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
|
|
12
|
+
"**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
|
|
11
13
|
"**/__tests__/**",
|
|
12
|
-
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc}.config.{js,cjs,mjs,ts}",
|
|
14
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
|
|
13
15
|
"**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
|
|
14
16
|
];
|
|
15
17
|
const coverageConfigDefaults = {
|
|
@@ -49,6 +51,7 @@ const config = {
|
|
|
49
51
|
exclude: defaultExclude,
|
|
50
52
|
testTimeout: 5e3,
|
|
51
53
|
hookTimeout: 1e4,
|
|
54
|
+
teardownTimeout: 1e3,
|
|
52
55
|
isolate: true,
|
|
53
56
|
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
54
57
|
forceRerunTriggers: [
|
package/dist/entry.mjs
CHANGED
|
@@ -1,17 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import './chunk-
|
|
1
|
+
import { promises } from 'fs';
|
|
2
|
+
import { g as getWorkerState, a as resetModules } from './chunk-utils-global.2aa95025.mjs';
|
|
3
|
+
import { f as envs } from './chunk-defaults.408a0cfe.mjs';
|
|
4
|
+
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.d82dd2cf.mjs';
|
|
5
|
+
import 'path';
|
|
4
6
|
import 'tty';
|
|
5
7
|
import 'local-pkg';
|
|
6
|
-
import 'path';
|
|
7
|
-
import './chunk-env-node.aa51c4cc.mjs';
|
|
8
8
|
import 'module';
|
|
9
9
|
import 'url';
|
|
10
|
-
import './chunk-runtime-
|
|
10
|
+
import './chunk-runtime-hooks.db398170.mjs';
|
|
11
|
+
import './chunk-runtime-chain.1e1aabb3.mjs';
|
|
12
|
+
import 'util';
|
|
11
13
|
import 'chai';
|
|
12
14
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
13
|
-
import './chunk-runtime-rpc.
|
|
14
|
-
import './chunk-utils-source-map.
|
|
15
|
-
import './
|
|
15
|
+
import './chunk-runtime-rpc.45d8ee19.mjs';
|
|
16
|
+
import './chunk-utils-source-map.8b066ce2.mjs';
|
|
17
|
+
import './spy.mjs';
|
|
16
18
|
import 'tinyspy';
|
|
17
|
-
|
|
19
|
+
|
|
20
|
+
async function run(files, config) {
|
|
21
|
+
await setupGlobalEnv(config);
|
|
22
|
+
const workerState = getWorkerState();
|
|
23
|
+
if (config.browser) {
|
|
24
|
+
workerState.mockMap.clear();
|
|
25
|
+
await startTests(files, config);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const filesWithEnv = await Promise.all(files.map(async (file) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const code = await promises.readFile(file, "utf-8");
|
|
31
|
+
const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
|
|
32
|
+
if (!envs.includes(env))
|
|
33
|
+
throw new Error(`Unsupported environment: "${env}" in ${file}`);
|
|
34
|
+
return {
|
|
35
|
+
file,
|
|
36
|
+
env
|
|
37
|
+
};
|
|
38
|
+
}));
|
|
39
|
+
const filesByEnv = filesWithEnv.reduce((acc, { file, env }) => {
|
|
40
|
+
acc[env] || (acc[env] = []);
|
|
41
|
+
acc[env].push(file);
|
|
42
|
+
return acc;
|
|
43
|
+
}, {});
|
|
44
|
+
for (const env of envs) {
|
|
45
|
+
const environment = env;
|
|
46
|
+
const files2 = filesByEnv[environment];
|
|
47
|
+
if (!files2 || !files2.length)
|
|
48
|
+
continue;
|
|
49
|
+
await withEnv(environment, config.environmentOptions || {}, async () => {
|
|
50
|
+
for (const file of files2) {
|
|
51
|
+
workerState.mockMap.clear();
|
|
52
|
+
resetModules();
|
|
53
|
+
workerState.filepath = file;
|
|
54
|
+
await startTests([file], config);
|
|
55
|
+
workerState.filepath = void 0;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { run };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ViteDevServer, TransformResult, CommonServerOptions } from 'vite';
|
|
1
|
+
import { ViteDevServer, TransformResult, CommonServerOptions, AliasOptions } from 'vite';
|
|
2
2
|
import { Stats } from 'fs';
|
|
3
3
|
import { SpyImpl } from 'tinyspy';
|
|
4
4
|
import { MessagePort } from 'worker_threads';
|
|
5
|
-
|
|
5
|
+
import * as chai from 'chai';
|
|
6
|
+
export { chai };
|
|
7
|
+
export { assert, should } from 'chai';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
@@ -207,26 +209,18 @@ interface CustomEventMap {
|
|
|
207
209
|
type InferCustomEventPayload<T extends string> =
|
|
208
210
|
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
209
211
|
|
|
210
|
-
type ModuleNamespace = Record<string, any> & {
|
|
211
|
-
[Symbol.toStringTag]: 'Module'
|
|
212
|
-
}
|
|
213
|
-
|
|
214
212
|
interface ViteHotContext {
|
|
215
213
|
readonly data: any
|
|
216
214
|
|
|
217
215
|
accept(): void
|
|
218
|
-
accept(cb: (mod:
|
|
219
|
-
accept(dep: string, cb: (mod:
|
|
220
|
-
accept(
|
|
221
|
-
deps: readonly string[],
|
|
222
|
-
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
223
|
-
): void
|
|
216
|
+
accept(cb: (mod: any) => void): void
|
|
217
|
+
accept(dep: string, cb: (mod: any) => void): void
|
|
218
|
+
accept(deps: readonly string[], cb: (mods: any[]) => void): void
|
|
224
219
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
): void
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated
|
|
222
|
+
*/
|
|
223
|
+
acceptDeps(): never
|
|
230
224
|
|
|
231
225
|
dispose(cb: (data: any) => void): void
|
|
232
226
|
decline(): void
|
|
@@ -380,6 +374,53 @@ interface WorkerPool {
|
|
|
380
374
|
close: () => Promise<void>;
|
|
381
375
|
}
|
|
382
376
|
|
|
377
|
+
declare class StateManager {
|
|
378
|
+
filesMap: Map<string, File>;
|
|
379
|
+
pathsSet: Set<string>;
|
|
380
|
+
idMap: Map<string, Task>;
|
|
381
|
+
taskFileMap: WeakMap<Task, File>;
|
|
382
|
+
errorsSet: Set<unknown>;
|
|
383
|
+
catchError(err: unknown, type: string): void;
|
|
384
|
+
clearErrors(): void;
|
|
385
|
+
getUnhandledErrors(): unknown[];
|
|
386
|
+
getPaths(): string[];
|
|
387
|
+
getFiles(keys?: string[]): File[];
|
|
388
|
+
getFilepaths(): string[];
|
|
389
|
+
getFailedFilepaths(): string[];
|
|
390
|
+
collectPaths(paths?: string[]): void;
|
|
391
|
+
collectFiles(files?: File[]): void;
|
|
392
|
+
clearFiles(paths?: string[]): void;
|
|
393
|
+
updateId(task: Task): void;
|
|
394
|
+
updateTasks(packs: TaskResultPack[]): void;
|
|
395
|
+
updateUserLog(log: UserConsoleLog): void;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
declare class Logger {
|
|
399
|
+
ctx: Vitest;
|
|
400
|
+
console: Console;
|
|
401
|
+
outputStream: NodeJS.WriteStream & {
|
|
402
|
+
fd: 1;
|
|
403
|
+
};
|
|
404
|
+
errorStream: NodeJS.WriteStream & {
|
|
405
|
+
fd: 2;
|
|
406
|
+
};
|
|
407
|
+
logUpdate: ((...text: string[]) => void) & {
|
|
408
|
+
clear(): void;
|
|
409
|
+
done(): void;
|
|
410
|
+
};
|
|
411
|
+
private _clearScreenPending;
|
|
412
|
+
constructor(ctx: Vitest, console?: Console);
|
|
413
|
+
log(...args: any[]): void;
|
|
414
|
+
error(...args: any[]): void;
|
|
415
|
+
warn(...args: any[]): void;
|
|
416
|
+
clearScreen(message: string, force?: boolean): void;
|
|
417
|
+
private _clearScreen;
|
|
418
|
+
printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
|
|
419
|
+
printNoTestFound(filters?: string[]): void;
|
|
420
|
+
printBanner(): void;
|
|
421
|
+
printUnhandledErrors(errors: unknown[]): Promise<void>;
|
|
422
|
+
}
|
|
423
|
+
|
|
383
424
|
interface SuiteResultCache {
|
|
384
425
|
failed: boolean;
|
|
385
426
|
duration: number;
|
|
@@ -389,6 +430,7 @@ declare class ResultsCache {
|
|
|
389
430
|
private cachePath;
|
|
390
431
|
private version;
|
|
391
432
|
private root;
|
|
433
|
+
getCachePath(): string | null;
|
|
392
434
|
setConfig(root: string, config: ResolvedConfig['cache']): void;
|
|
393
435
|
getResults(fsPath: string): SuiteResultCache | undefined;
|
|
394
436
|
readFromCache(): Promise<void>;
|
|
@@ -397,6 +439,13 @@ declare class ResultsCache {
|
|
|
397
439
|
writeToCache(): Promise<void>;
|
|
398
440
|
}
|
|
399
441
|
|
|
442
|
+
interface CliOptions extends UserConfig {
|
|
443
|
+
/**
|
|
444
|
+
* Override the watch mode
|
|
445
|
+
*/
|
|
446
|
+
run?: boolean;
|
|
447
|
+
}
|
|
448
|
+
|
|
400
449
|
declare type FileStatsCache = Pick<Stats, 'size'>;
|
|
401
450
|
declare class FilesStatsCache {
|
|
402
451
|
cache: Map<string, FileStatsCache>;
|
|
@@ -405,27 +454,18 @@ declare class FilesStatsCache {
|
|
|
405
454
|
removeStats(fsPath: string): void;
|
|
406
455
|
}
|
|
407
456
|
|
|
408
|
-
declare class
|
|
409
|
-
filesMap: Map<string, File>;
|
|
410
|
-
idMap: Map<string, Task>;
|
|
411
|
-
taskFileMap: WeakMap<Task, File>;
|
|
412
|
-
errorsSet: Set<unknown>;
|
|
457
|
+
declare class VitestCache {
|
|
413
458
|
results: ResultsCache;
|
|
414
459
|
stats: FilesStatsCache;
|
|
415
460
|
getFileTestResults(id: string): SuiteResultCache | undefined;
|
|
416
461
|
getFileStats(id: string): {
|
|
417
462
|
size: number;
|
|
418
463
|
} | undefined;
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
getFailedFilepaths(): string[];
|
|
425
|
-
collectFiles(files?: File[]): void;
|
|
426
|
-
updateId(task: Task): void;
|
|
427
|
-
updateTasks(packs: TaskResultPack[]): void;
|
|
428
|
-
updateUserLog(log: UserConsoleLog): void;
|
|
464
|
+
static resolveCacheDir(root: string, dir: string | undefined): string;
|
|
465
|
+
static clearCache(options: CliOptions): Promise<{
|
|
466
|
+
dir: string;
|
|
467
|
+
cleared: boolean;
|
|
468
|
+
}>;
|
|
429
469
|
}
|
|
430
470
|
|
|
431
471
|
declare class Vitest {
|
|
@@ -434,15 +474,10 @@ declare class Vitest {
|
|
|
434
474
|
server: ViteDevServer;
|
|
435
475
|
state: StateManager;
|
|
436
476
|
snapshot: SnapshotManager;
|
|
477
|
+
cache: VitestCache;
|
|
437
478
|
reporters: Reporter[];
|
|
438
|
-
|
|
479
|
+
logger: Logger;
|
|
439
480
|
pool: WorkerPool | undefined;
|
|
440
|
-
outputStream: NodeJS.WriteStream & {
|
|
441
|
-
fd: 1;
|
|
442
|
-
};
|
|
443
|
-
errorStream: NodeJS.WriteStream & {
|
|
444
|
-
fd: 2;
|
|
445
|
-
};
|
|
446
481
|
vitenode: ViteNodeServer;
|
|
447
482
|
invalidates: Set<string>;
|
|
448
483
|
changedTests: Set<string>;
|
|
@@ -451,8 +486,8 @@ declare class Vitest {
|
|
|
451
486
|
isFirstRun: boolean;
|
|
452
487
|
restartsCount: number;
|
|
453
488
|
runner: ViteNodeRunner;
|
|
454
|
-
private _onRestartListeners;
|
|
455
489
|
constructor();
|
|
490
|
+
private _onRestartListeners;
|
|
456
491
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
457
492
|
getSerializableConfig(): ResolvedConfig;
|
|
458
493
|
start(filters?: string[]): Promise<void>;
|
|
@@ -463,9 +498,6 @@ declare class Vitest {
|
|
|
463
498
|
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
464
499
|
rerunFailed(): Promise<void>;
|
|
465
500
|
updateSnapshot(files?: string[]): Promise<void>;
|
|
466
|
-
log(...args: any[]): void;
|
|
467
|
-
error(...args: any[]): void;
|
|
468
|
-
clearScreen(): void;
|
|
469
501
|
private _rerunTimer;
|
|
470
502
|
private scheduleRerun;
|
|
471
503
|
private unregisterWatcher;
|
|
@@ -480,7 +512,6 @@ declare class Vitest {
|
|
|
480
512
|
globTestFiles(filters?: string[]): Promise<string[]>;
|
|
481
513
|
isTargetFile(id: string, source?: string): Promise<boolean>;
|
|
482
514
|
isInSourceTestFile(code: string): boolean;
|
|
483
|
-
printError(err: unknown, fullStack?: boolean, type?: string): Promise<void>;
|
|
484
515
|
onServerRestarted(fn: () => void): void;
|
|
485
516
|
}
|
|
486
517
|
|
|
@@ -494,7 +525,7 @@ interface TestSequencer {
|
|
|
494
525
|
shard(files: string[]): Awaitable<string[]>;
|
|
495
526
|
sort(files: string[]): Awaitable<string[]>;
|
|
496
527
|
}
|
|
497
|
-
interface
|
|
528
|
+
interface TestSequencerConstructor {
|
|
498
529
|
new (ctx: Vitest): TestSequencer;
|
|
499
530
|
}
|
|
500
531
|
|
|
@@ -502,14 +533,19 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
502
533
|
start: number;
|
|
503
534
|
end: number;
|
|
504
535
|
watchFilters?: string[];
|
|
505
|
-
isTTY:
|
|
536
|
+
isTTY: false;
|
|
506
537
|
ctx: Vitest;
|
|
538
|
+
private _filesInWatchMode;
|
|
539
|
+
private _lastRunTimeout;
|
|
540
|
+
private _lastRunTimer;
|
|
541
|
+
private _lastRunCount;
|
|
507
542
|
constructor();
|
|
508
543
|
onInit(ctx: Vitest): void;
|
|
509
544
|
relative(path: string): string;
|
|
510
545
|
onFinished(files?: File[], errors?: unknown[]): Promise<void>;
|
|
511
546
|
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
512
547
|
onWatcherStart(): Promise<void>;
|
|
548
|
+
private resetLastRunLog;
|
|
513
549
|
onWatcherRerun(files: string[], trigger?: string): Promise<void>;
|
|
514
550
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
515
551
|
shouldLog(log: UserConsoleLog): boolean;
|
|
@@ -521,7 +557,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
521
557
|
|
|
522
558
|
interface ListRendererOptions {
|
|
523
559
|
renderSucceed?: boolean;
|
|
524
|
-
|
|
560
|
+
logger: Logger;
|
|
525
561
|
showHeap: boolean;
|
|
526
562
|
}
|
|
527
563
|
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
@@ -553,6 +589,10 @@ declare class DotReporter extends BaseReporter {
|
|
|
553
589
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
554
590
|
}
|
|
555
591
|
|
|
592
|
+
interface Callsite {
|
|
593
|
+
line: number;
|
|
594
|
+
column: number;
|
|
595
|
+
}
|
|
556
596
|
declare class JsonReporter implements Reporter {
|
|
557
597
|
start: number;
|
|
558
598
|
ctx: Vitest;
|
|
@@ -565,6 +605,7 @@ declare class JsonReporter implements Reporter {
|
|
|
565
605
|
* @param report
|
|
566
606
|
*/
|
|
567
607
|
writeReport(report: string): Promise<void>;
|
|
608
|
+
protected getFailureLocation(test: Test): Callsite | undefined;
|
|
568
609
|
}
|
|
569
610
|
|
|
570
611
|
declare class VerboseReporter extends DefaultReporter {
|
|
@@ -880,22 +921,24 @@ interface EachFunction {
|
|
|
880
921
|
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
|
|
881
922
|
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
882
923
|
}
|
|
883
|
-
declare type
|
|
924
|
+
declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
884
925
|
name: string,
|
|
885
926
|
fn?: TestFunction<ExtraContext>,
|
|
886
927
|
timeout?: number
|
|
887
|
-
], void
|
|
928
|
+
], void>;
|
|
929
|
+
declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
|
|
888
930
|
each: EachFunction;
|
|
889
|
-
skipIf(condition: any):
|
|
890
|
-
runIf(condition: any):
|
|
931
|
+
skipIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
932
|
+
runIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
891
933
|
};
|
|
892
|
-
declare type
|
|
934
|
+
declare type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
|
|
893
935
|
name: string,
|
|
894
936
|
factory?: SuiteFactory
|
|
895
|
-
], SuiteCollector<ExtraContext
|
|
937
|
+
], SuiteCollector<ExtraContext>>;
|
|
938
|
+
declare type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI & {
|
|
896
939
|
each: EachFunction;
|
|
897
|
-
skipIf(condition: any):
|
|
898
|
-
runIf(condition: any):
|
|
940
|
+
skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
941
|
+
runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
899
942
|
};
|
|
900
943
|
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
901
944
|
declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
@@ -937,6 +980,7 @@ interface TestContext {
|
|
|
937
980
|
|
|
938
981
|
interface Reporter {
|
|
939
982
|
onInit?(ctx: Vitest): void;
|
|
983
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
940
984
|
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
941
985
|
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
942
986
|
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
@@ -1147,6 +1191,12 @@ interface InlineConfig {
|
|
|
1147
1191
|
* @default 10000
|
|
1148
1192
|
*/
|
|
1149
1193
|
hookTimeout?: number;
|
|
1194
|
+
/**
|
|
1195
|
+
* Default timeout to wait for close when Vitest shuts down, in milliseconds
|
|
1196
|
+
*
|
|
1197
|
+
* @default 1000
|
|
1198
|
+
*/
|
|
1199
|
+
teardownTimeout?: number;
|
|
1150
1200
|
/**
|
|
1151
1201
|
* Silent mode
|
|
1152
1202
|
*
|
|
@@ -1215,6 +1265,11 @@ interface InlineConfig {
|
|
|
1215
1265
|
* @internal WIP
|
|
1216
1266
|
*/
|
|
1217
1267
|
ui?: boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Use in browser environment
|
|
1270
|
+
* @experimental
|
|
1271
|
+
*/
|
|
1272
|
+
browser?: boolean;
|
|
1218
1273
|
/**
|
|
1219
1274
|
* Open UI automatically.
|
|
1220
1275
|
*
|
|
@@ -1314,7 +1369,7 @@ interface InlineConfig {
|
|
|
1314
1369
|
* your custom sequencer from `BaseSequencer` from `vitest/node`.
|
|
1315
1370
|
* @default BaseSequencer
|
|
1316
1371
|
*/
|
|
1317
|
-
sequencer?:
|
|
1372
|
+
sequencer?: TestSequencerConstructor;
|
|
1318
1373
|
/**
|
|
1319
1374
|
* Should tests run in random order.
|
|
1320
1375
|
* @default false
|
|
@@ -1326,6 +1381,12 @@ interface InlineConfig {
|
|
|
1326
1381
|
*/
|
|
1327
1382
|
seed?: number;
|
|
1328
1383
|
};
|
|
1384
|
+
/**
|
|
1385
|
+
* Specifies an `Object`, or an `Array` of `Object`,
|
|
1386
|
+
* which defines aliases used to replace values in `import` or `require` statements.
|
|
1387
|
+
* Will be merged with the default aliases inside `resolve.alias`.
|
|
1388
|
+
*/
|
|
1389
|
+
alias?: AliasOptions;
|
|
1329
1390
|
}
|
|
1330
1391
|
interface UserConfig extends InlineConfig {
|
|
1331
1392
|
/**
|
|
@@ -1384,7 +1445,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
1384
1445
|
dir: string;
|
|
1385
1446
|
} | false;
|
|
1386
1447
|
sequence: {
|
|
1387
|
-
sequencer:
|
|
1448
|
+
sequencer: TestSequencerConstructor;
|
|
1388
1449
|
shuffle?: boolean;
|
|
1389
1450
|
seed?: number;
|
|
1390
1451
|
};
|
|
@@ -1677,6 +1738,7 @@ interface WorkerRPC {
|
|
|
1677
1738
|
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
1678
1739
|
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
1679
1740
|
onWorkerExit: (code?: number) => void;
|
|
1741
|
+
onPathsCollected: (paths: string[]) => void;
|
|
1680
1742
|
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
1681
1743
|
onUnhandledRejection: (err: unknown) => void;
|
|
1682
1744
|
onCollected: (files: File[]) => void;
|
|
@@ -1691,6 +1753,7 @@ interface WorkerGlobalState {
|
|
|
1691
1753
|
current?: Test;
|
|
1692
1754
|
filepath?: string;
|
|
1693
1755
|
moduleCache: ModuleCacheMap;
|
|
1756
|
+
browserHashMap?: Map<string, string>;
|
|
1694
1757
|
mockMap: MockMap;
|
|
1695
1758
|
}
|
|
1696
1759
|
|
|
@@ -1926,7 +1989,12 @@ interface TransformResultWithSource extends TransformResult {
|
|
|
1926
1989
|
source?: string;
|
|
1927
1990
|
}
|
|
1928
1991
|
interface WebSocketHandlers {
|
|
1992
|
+
onWatcherStart: () => Promise<void>;
|
|
1993
|
+
onFinished(files?: File[]): Promise<void>;
|
|
1994
|
+
onCollected(files?: File[]): Promise<void>;
|
|
1995
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1929
1996
|
getFiles(): File[];
|
|
1997
|
+
getPaths(): string[];
|
|
1930
1998
|
getConfig(): ResolvedConfig;
|
|
1931
1999
|
getModuleGraph(id: string): Promise<ModuleGraphData>;
|
|
1932
2000
|
getTransformResult(id: string): Promise<TransformResultWithSource | undefined>;
|
|
@@ -1935,7 +2003,7 @@ interface WebSocketHandlers {
|
|
|
1935
2003
|
rerun(files: string[]): Promise<void>;
|
|
1936
2004
|
updateSnapshot(file?: File): Promise<void>;
|
|
1937
2005
|
}
|
|
1938
|
-
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog'> {
|
|
2006
|
+
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
|
|
1939
2007
|
}
|
|
1940
2008
|
|
|
1941
2009
|
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable$1 as Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyInstance, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TransformResultWithSource, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, createExpect, describe, globalExpect as expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
export { c as
|
|
2
|
-
export {
|
|
3
|
-
import '
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.1e1aabb3.mjs';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.db398170.mjs';
|
|
3
|
+
import * as chai from 'chai';
|
|
4
|
+
export { chai };
|
|
5
|
+
export { assert, should } from 'chai';
|
|
6
|
+
import 'util';
|
|
7
|
+
import './chunk-utils-global.2aa95025.mjs';
|
|
8
|
+
import 'path';
|
|
6
9
|
import 'tty';
|
|
7
10
|
import 'local-pkg';
|
|
8
|
-
import '
|
|
11
|
+
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
|
+
import './chunk-runtime-rpc.45d8ee19.mjs';
|
|
9
13
|
import 'fs';
|
|
10
|
-
import './chunk-utils-source-map.
|
|
11
|
-
import './
|
|
14
|
+
import './chunk-utils-source-map.8b066ce2.mjs';
|
|
15
|
+
import './spy.mjs';
|
|
12
16
|
import 'tinyspy';
|
|
13
|
-
import 'util';
|