vitest 0.18.0 → 0.19.1
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.63babd7c.mjs → chunk-api-setup.0cf2c96a.mjs} +37 -11
- package/dist/{chunk-constants.8eb2ed35.mjs → chunk-constants.38b43a44.mjs} +3 -3
- package/dist/{chunk-env-node.26c72624.mjs → chunk-defaults.ed196a9a.mjs} +458 -455
- package/dist/{chunk-install-pkg.2dcb2c04.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
- package/dist/chunk-integrations-globals.1018e651.mjs +24 -0
- package/dist/chunk-node-git.9058b82a.mjs +1139 -0
- package/dist/chunk-runtime-chain.f2e00f4c.mjs +2039 -0
- package/dist/{vendor-entry.78de67ab.mjs → chunk-runtime-error.606e0393.mjs} +167 -183
- package/dist/{chunk-runtime-chain.eb764dff.mjs → chunk-runtime-hooks.d4cadf47.mjs} +33 -2012
- package/dist/{chunk-runtime-mocker.79ccc3de.mjs → chunk-runtime-mocker.dfdfd57b.mjs} +70 -22
- package/dist/{chunk-runtime-rpc.cc6a06a2.mjs → chunk-runtime-rpc.45d8ee19.mjs} +1 -1
- package/dist/{chunk-utils-global.1b22c4fd.mjs → chunk-utils-global.2aa95025.mjs} +11 -6
- package/dist/{chunk-utils-source-map.957e7756.mjs → chunk-utils-source-map.8b066ce2.mjs} +2 -2
- package/dist/{chunk-vite-node-externalize.0791f2ed.mjs → chunk-vite-node-externalize.e9af6472.mjs} +105 -1174
- package/dist/chunk-vite-node-utils.ad73f2ab.mjs +1433 -0
- package/dist/cli.mjs +9 -11
- 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 +56 -27
- package/dist/index.mjs +12 -9
- package/dist/node.d.ts +37 -18
- package/dist/node.mjs +10 -12
- package/dist/spy.mjs +102 -2
- package/dist/suite.mjs +13 -0
- package/dist/vendor-index.61438b77.mjs +335 -0
- package/dist/{vendor-index.4bf9c627.mjs → vendor-index.62ce5c33.mjs} +11 -343
- package/dist/worker.mjs +6 -6
- package/package.json +20 -12
- package/dist/chunk-integrations-globals.61e4d6ae.mjs +0 -26
- package/dist/chunk-integrations-spy.674b628e.mjs +0 -102
- package/dist/chunk-vite-node-utils.af8ead96.mjs +0 -9195
package/dist/cli.mjs
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
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.e9af6472.mjs';
|
|
4
|
+
import 'path';
|
|
4
5
|
import 'tty';
|
|
5
6
|
import 'local-pkg';
|
|
6
|
-
import '
|
|
7
|
-
import './chunk-env-node.26c72624.mjs';
|
|
7
|
+
import './chunk-defaults.ed196a9a.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.
|
|
13
|
+
import './chunk-constants.38b43a44.mjs';
|
|
14
14
|
import 'os';
|
|
15
15
|
import 'util';
|
|
16
16
|
import 'stream';
|
|
17
17
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
18
|
-
import './chunk-vite-node-utils.
|
|
18
|
+
import './chunk-vite-node-utils.ad73f2ab.mjs';
|
|
19
19
|
import 'vm';
|
|
20
20
|
import 'assert';
|
|
21
21
|
import 'debug';
|
|
22
22
|
import 'worker_threads';
|
|
23
23
|
import 'tinypool';
|
|
24
24
|
import 'perf_hooks';
|
|
25
|
-
import './chunk-utils-source-map.
|
|
25
|
+
import './chunk-utils-source-map.8b066ce2.mjs';
|
|
26
26
|
import 'crypto';
|
|
27
|
-
import '
|
|
28
|
-
import 'child_process';
|
|
29
|
-
import './vendor-index.4bf9c627.mjs';
|
|
27
|
+
import './vendor-index.61438b77.mjs';
|
|
30
28
|
import './chunk-magic-string.efe26975.mjs';
|
|
31
29
|
import 'readline';
|
|
32
30
|
import './vendor-index.de788b6a.mjs';
|
|
@@ -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.ed196a9a.mjs';
|
|
4
|
+
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.606e0393.mjs';
|
|
5
|
+
import 'path';
|
|
4
6
|
import 'tty';
|
|
5
7
|
import 'local-pkg';
|
|
6
|
-
import 'path';
|
|
7
|
-
import './chunk-env-node.26c72624.mjs';
|
|
8
8
|
import 'module';
|
|
9
9
|
import 'url';
|
|
10
|
-
import './chunk-runtime-
|
|
10
|
+
import './chunk-runtime-hooks.d4cadf47.mjs';
|
|
11
|
+
import './chunk-runtime-chain.f2e00f4c.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
|
|
@@ -382,15 +376,18 @@ interface WorkerPool {
|
|
|
382
376
|
|
|
383
377
|
declare class StateManager {
|
|
384
378
|
filesMap: Map<string, File>;
|
|
379
|
+
pathsSet: Set<string>;
|
|
385
380
|
idMap: Map<string, Task>;
|
|
386
381
|
taskFileMap: WeakMap<Task, File>;
|
|
387
382
|
errorsSet: Set<unknown>;
|
|
388
383
|
catchError(err: unknown, type: string): void;
|
|
389
384
|
clearErrors(): void;
|
|
390
385
|
getUnhandledErrors(): unknown[];
|
|
386
|
+
getPaths(): string[];
|
|
391
387
|
getFiles(keys?: string[]): File[];
|
|
392
388
|
getFilepaths(): string[];
|
|
393
389
|
getFailedFilepaths(): string[];
|
|
390
|
+
collectPaths(paths?: string[]): void;
|
|
394
391
|
collectFiles(files?: File[]): void;
|
|
395
392
|
clearFiles(paths?: string[]): void;
|
|
396
393
|
updateId(task: Task): void;
|
|
@@ -536,7 +533,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
536
533
|
start: number;
|
|
537
534
|
end: number;
|
|
538
535
|
watchFilters?: string[];
|
|
539
|
-
isTTY:
|
|
536
|
+
isTTY: false;
|
|
540
537
|
ctx: Vitest;
|
|
541
538
|
private _filesInWatchMode;
|
|
542
539
|
private _lastRunTimeout;
|
|
@@ -592,6 +589,10 @@ declare class DotReporter extends BaseReporter {
|
|
|
592
589
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
593
590
|
}
|
|
594
591
|
|
|
592
|
+
interface Callsite {
|
|
593
|
+
line: number;
|
|
594
|
+
column: number;
|
|
595
|
+
}
|
|
595
596
|
declare class JsonReporter implements Reporter {
|
|
596
597
|
start: number;
|
|
597
598
|
ctx: Vitest;
|
|
@@ -604,6 +605,7 @@ declare class JsonReporter implements Reporter {
|
|
|
604
605
|
* @param report
|
|
605
606
|
*/
|
|
606
607
|
writeReport(report: string): Promise<void>;
|
|
608
|
+
protected getFailureLocation(test: Test): Callsite | undefined;
|
|
607
609
|
}
|
|
608
610
|
|
|
609
611
|
declare class VerboseReporter extends DefaultReporter {
|
|
@@ -919,22 +921,24 @@ interface EachFunction {
|
|
|
919
921
|
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
|
|
920
922
|
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
921
923
|
}
|
|
922
|
-
declare type
|
|
924
|
+
declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
923
925
|
name: string,
|
|
924
926
|
fn?: TestFunction<ExtraContext>,
|
|
925
927
|
timeout?: number
|
|
926
|
-
], void
|
|
928
|
+
], void>;
|
|
929
|
+
declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
|
|
927
930
|
each: EachFunction;
|
|
928
|
-
skipIf(condition: any):
|
|
929
|
-
runIf(condition: any):
|
|
931
|
+
skipIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
932
|
+
runIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
930
933
|
};
|
|
931
|
-
declare type
|
|
934
|
+
declare type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
|
|
932
935
|
name: string,
|
|
933
936
|
factory?: SuiteFactory
|
|
934
|
-
], SuiteCollector<ExtraContext
|
|
937
|
+
], SuiteCollector<ExtraContext>>;
|
|
938
|
+
declare type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI & {
|
|
935
939
|
each: EachFunction;
|
|
936
|
-
skipIf(condition: any):
|
|
937
|
-
runIf(condition: any):
|
|
940
|
+
skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
941
|
+
runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
938
942
|
};
|
|
939
943
|
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
940
944
|
declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
@@ -976,6 +980,7 @@ interface TestContext {
|
|
|
976
980
|
|
|
977
981
|
interface Reporter {
|
|
978
982
|
onInit?(ctx: Vitest): void;
|
|
983
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
979
984
|
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
980
985
|
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
981
986
|
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
@@ -1186,6 +1191,12 @@ interface InlineConfig {
|
|
|
1186
1191
|
* @default 10000
|
|
1187
1192
|
*/
|
|
1188
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;
|
|
1189
1200
|
/**
|
|
1190
1201
|
* Silent mode
|
|
1191
1202
|
*
|
|
@@ -1254,6 +1265,11 @@ interface InlineConfig {
|
|
|
1254
1265
|
* @internal WIP
|
|
1255
1266
|
*/
|
|
1256
1267
|
ui?: boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Use in browser environment
|
|
1270
|
+
* @experimental
|
|
1271
|
+
*/
|
|
1272
|
+
browser?: boolean;
|
|
1257
1273
|
/**
|
|
1258
1274
|
* Open UI automatically.
|
|
1259
1275
|
*
|
|
@@ -1365,6 +1381,12 @@ interface InlineConfig {
|
|
|
1365
1381
|
*/
|
|
1366
1382
|
seed?: number;
|
|
1367
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;
|
|
1368
1390
|
}
|
|
1369
1391
|
interface UserConfig extends InlineConfig {
|
|
1370
1392
|
/**
|
|
@@ -1716,6 +1738,7 @@ interface WorkerRPC {
|
|
|
1716
1738
|
getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
|
|
1717
1739
|
onFinished: (files: File[], errors?: unknown[]) => void;
|
|
1718
1740
|
onWorkerExit: (code?: number) => void;
|
|
1741
|
+
onPathsCollected: (paths: string[]) => void;
|
|
1719
1742
|
onUserConsoleLog: (log: UserConsoleLog) => void;
|
|
1720
1743
|
onUnhandledRejection: (err: unknown) => void;
|
|
1721
1744
|
onCollected: (files: File[]) => void;
|
|
@@ -1730,6 +1753,7 @@ interface WorkerGlobalState {
|
|
|
1730
1753
|
current?: Test;
|
|
1731
1754
|
filepath?: string;
|
|
1732
1755
|
moduleCache: ModuleCacheMap;
|
|
1756
|
+
browserHashMap?: Map<string, string>;
|
|
1733
1757
|
mockMap: MockMap;
|
|
1734
1758
|
}
|
|
1735
1759
|
|
|
@@ -1965,7 +1989,12 @@ interface TransformResultWithSource extends TransformResult {
|
|
|
1965
1989
|
source?: string;
|
|
1966
1990
|
}
|
|
1967
1991
|
interface WebSocketHandlers {
|
|
1992
|
+
onWatcherStart: () => Promise<void>;
|
|
1993
|
+
onFinished(files?: File[]): Promise<void>;
|
|
1994
|
+
onCollected(files?: File[]): Promise<void>;
|
|
1995
|
+
onTaskUpdate(packs: TaskResultPack[]): void;
|
|
1968
1996
|
getFiles(): File[];
|
|
1997
|
+
getPaths(): string[];
|
|
1969
1998
|
getConfig(): ResolvedConfig;
|
|
1970
1999
|
getModuleGraph(id: string): Promise<ModuleGraphData>;
|
|
1971
2000
|
getTransformResult(id: string): Promise<TransformResultWithSource | undefined>;
|
|
@@ -1974,7 +2003,7 @@ interface WebSocketHandlers {
|
|
|
1974
2003
|
rerun(files: string[]): Promise<void>;
|
|
1975
2004
|
updateSnapshot(file?: File): Promise<void>;
|
|
1976
2005
|
}
|
|
1977
|
-
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog'> {
|
|
2006
|
+
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
|
|
1978
2007
|
}
|
|
1979
2008
|
|
|
1980
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.f2e00f4c.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.d4cadf47.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';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ViteDevServer, TransformResult, CommonServerOptions, UserConfig as UserConfig$1, Plugin as Plugin$1 } from 'vite';
|
|
1
|
+
import { ViteDevServer, TransformResult, AliasOptions, CommonServerOptions, UserConfig as UserConfig$1, Plugin as Plugin$1 } from 'vite';
|
|
2
2
|
import { Stats } from 'fs';
|
|
3
3
|
|
|
4
4
|
interface UpdatePayload {
|
|
@@ -51,26 +51,18 @@ interface CustomEventMap {
|
|
|
51
51
|
type InferCustomEventPayload<T extends string> =
|
|
52
52
|
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
53
53
|
|
|
54
|
-
type ModuleNamespace = Record<string, any> & {
|
|
55
|
-
[Symbol.toStringTag]: 'Module'
|
|
56
|
-
}
|
|
57
|
-
|
|
58
54
|
interface ViteHotContext {
|
|
59
55
|
readonly data: any
|
|
60
56
|
|
|
61
57
|
accept(): void
|
|
62
|
-
accept(cb: (mod:
|
|
63
|
-
accept(dep: string, cb: (mod:
|
|
64
|
-
accept(
|
|
65
|
-
deps: readonly string[],
|
|
66
|
-
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
67
|
-
): void
|
|
58
|
+
accept(cb: (mod: any) => void): void
|
|
59
|
+
accept(dep: string, cb: (mod: any) => void): void
|
|
60
|
+
accept(deps: readonly string[], cb: (mods: any[]) => void): void
|
|
68
61
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
): void
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated
|
|
64
|
+
*/
|
|
65
|
+
acceptDeps(): never
|
|
74
66
|
|
|
75
67
|
dispose(cb: (data: any) => void): void
|
|
76
68
|
decline(): void
|
|
@@ -365,7 +357,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
365
357
|
start: number;
|
|
366
358
|
end: number;
|
|
367
359
|
watchFilters?: string[];
|
|
368
|
-
isTTY:
|
|
360
|
+
isTTY: false;
|
|
369
361
|
ctx: Vitest;
|
|
370
362
|
private _filesInWatchMode;
|
|
371
363
|
private _lastRunTimeout;
|
|
@@ -447,6 +439,10 @@ declare class DotReporter extends BaseReporter {
|
|
|
447
439
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
448
440
|
}
|
|
449
441
|
|
|
442
|
+
interface Callsite {
|
|
443
|
+
line: number;
|
|
444
|
+
column: number;
|
|
445
|
+
}
|
|
450
446
|
declare class JsonReporter implements Reporter {
|
|
451
447
|
start: number;
|
|
452
448
|
ctx: Vitest;
|
|
@@ -459,6 +455,7 @@ declare class JsonReporter implements Reporter {
|
|
|
459
455
|
* @param report
|
|
460
456
|
*/
|
|
461
457
|
writeReport(report: string): Promise<void>;
|
|
458
|
+
protected getFailureLocation(test: Test): Callsite | undefined;
|
|
462
459
|
}
|
|
463
460
|
|
|
464
461
|
declare class VerboseReporter extends DefaultReporter {
|
|
@@ -758,6 +755,7 @@ interface TestContext {
|
|
|
758
755
|
|
|
759
756
|
interface Reporter {
|
|
760
757
|
onInit?(ctx: Vitest): void;
|
|
758
|
+
onPathsCollected?: (paths?: string[]) => Awaitable<void>;
|
|
761
759
|
onCollected?: (files?: File[]) => Awaitable<void>;
|
|
762
760
|
onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
|
|
763
761
|
onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
|
|
@@ -967,6 +965,12 @@ interface InlineConfig {
|
|
|
967
965
|
* @default 10000
|
|
968
966
|
*/
|
|
969
967
|
hookTimeout?: number;
|
|
968
|
+
/**
|
|
969
|
+
* Default timeout to wait for close when Vitest shuts down, in milliseconds
|
|
970
|
+
*
|
|
971
|
+
* @default 1000
|
|
972
|
+
*/
|
|
973
|
+
teardownTimeout?: number;
|
|
970
974
|
/**
|
|
971
975
|
* Silent mode
|
|
972
976
|
*
|
|
@@ -1035,6 +1039,11 @@ interface InlineConfig {
|
|
|
1035
1039
|
* @internal WIP
|
|
1036
1040
|
*/
|
|
1037
1041
|
ui?: boolean;
|
|
1042
|
+
/**
|
|
1043
|
+
* Use in browser environment
|
|
1044
|
+
* @experimental
|
|
1045
|
+
*/
|
|
1046
|
+
browser?: boolean;
|
|
1038
1047
|
/**
|
|
1039
1048
|
* Open UI automatically.
|
|
1040
1049
|
*
|
|
@@ -1146,6 +1155,12 @@ interface InlineConfig {
|
|
|
1146
1155
|
*/
|
|
1147
1156
|
seed?: number;
|
|
1148
1157
|
};
|
|
1158
|
+
/**
|
|
1159
|
+
* Specifies an `Object`, or an `Array` of `Object`,
|
|
1160
|
+
* which defines aliases used to replace values in `import` or `require` statements.
|
|
1161
|
+
* Will be merged with the default aliases inside `resolve.alias`.
|
|
1162
|
+
*/
|
|
1163
|
+
alias?: AliasOptions;
|
|
1149
1164
|
}
|
|
1150
1165
|
interface UserConfig extends InlineConfig {
|
|
1151
1166
|
/**
|
|
@@ -1490,15 +1505,18 @@ interface WorkerPool {
|
|
|
1490
1505
|
|
|
1491
1506
|
declare class StateManager {
|
|
1492
1507
|
filesMap: Map<string, File>;
|
|
1508
|
+
pathsSet: Set<string>;
|
|
1493
1509
|
idMap: Map<string, Task>;
|
|
1494
1510
|
taskFileMap: WeakMap<Task, File>;
|
|
1495
1511
|
errorsSet: Set<unknown>;
|
|
1496
1512
|
catchError(err: unknown, type: string): void;
|
|
1497
1513
|
clearErrors(): void;
|
|
1498
1514
|
getUnhandledErrors(): unknown[];
|
|
1515
|
+
getPaths(): string[];
|
|
1499
1516
|
getFiles(keys?: string[]): File[];
|
|
1500
1517
|
getFilepaths(): string[];
|
|
1501
1518
|
getFailedFilepaths(): string[];
|
|
1519
|
+
collectPaths(paths?: string[]): void;
|
|
1502
1520
|
collectFiles(files?: File[]): void;
|
|
1503
1521
|
clearFiles(paths?: string[]): void;
|
|
1504
1522
|
updateId(task: Task): void;
|
|
@@ -1605,6 +1623,7 @@ declare function createVitest(options: UserConfig, viteOverrides?: UserConfig$1)
|
|
|
1605
1623
|
|
|
1606
1624
|
declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin$1[]>;
|
|
1607
1625
|
|
|
1626
|
+
declare type Key = string | symbol;
|
|
1608
1627
|
interface ViteRunnerRequest {
|
|
1609
1628
|
(dep: string): any;
|
|
1610
1629
|
callstack: string[];
|
|
@@ -1630,7 +1649,7 @@ declare class VitestMocker {
|
|
|
1630
1649
|
normalizePath(path: string): string;
|
|
1631
1650
|
getFsPath(path: string, external: string | null): string;
|
|
1632
1651
|
resolveMockPath(mockPath: string, external: string | null): string | null;
|
|
1633
|
-
|
|
1652
|
+
mockObject(object: Record<string | symbol, any>): Record<Key, any>;
|
|
1634
1653
|
unmockPath(path: string): void;
|
|
1635
1654
|
mockPath(path: string, external: string | null, factory?: () => any): void;
|
|
1636
1655
|
importActual<T>(id: string, importer: string): Promise<T>;
|
package/dist/node.mjs
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.e9af6472.mjs';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.dfdfd57b.mjs';
|
|
3
|
+
import './chunk-utils-global.2aa95025.mjs';
|
|
4
|
+
import 'path';
|
|
5
|
+
import 'tty';
|
|
4
6
|
import 'local-pkg';
|
|
7
|
+
import './chunk-defaults.ed196a9a.mjs';
|
|
5
8
|
import 'fs';
|
|
6
9
|
import 'module';
|
|
7
10
|
import 'url';
|
|
8
|
-
import './chunk-utils-global.1b22c4fd.mjs';
|
|
9
|
-
import 'tty';
|
|
10
|
-
import 'path';
|
|
11
11
|
import 'vite';
|
|
12
12
|
import 'process';
|
|
13
|
-
import './chunk-constants.
|
|
13
|
+
import './chunk-constants.38b43a44.mjs';
|
|
14
14
|
import 'os';
|
|
15
15
|
import 'util';
|
|
16
16
|
import 'stream';
|
|
17
17
|
import 'events';
|
|
18
18
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
19
|
-
import './chunk-vite-node-utils.
|
|
19
|
+
import './chunk-vite-node-utils.ad73f2ab.mjs';
|
|
20
20
|
import 'vm';
|
|
21
21
|
import 'assert';
|
|
22
22
|
import 'debug';
|
|
23
23
|
import 'worker_threads';
|
|
24
24
|
import 'tinypool';
|
|
25
25
|
import 'perf_hooks';
|
|
26
|
-
import './chunk-utils-source-map.
|
|
26
|
+
import './chunk-utils-source-map.8b066ce2.mjs';
|
|
27
27
|
import 'crypto';
|
|
28
|
-
import '
|
|
29
|
-
import 'child_process';
|
|
30
|
-
import './vendor-index.4bf9c627.mjs';
|
|
28
|
+
import './vendor-index.61438b77.mjs';
|
|
31
29
|
import './chunk-magic-string.efe26975.mjs';
|
|
32
30
|
import 'readline';
|
|
33
31
|
import './vendor-index.de788b6a.mjs';
|