vitest 0.15.1 → 0.17.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/dist/{chunk-api-setup.ff687d0e.mjs → chunk-api-setup.5282c6cb.mjs} +3 -3
- package/dist/{chunk-constants.7b9cfc82.mjs → chunk-constants.511c6e9b.mjs} +7 -1
- package/dist/chunk-env-node.dc514f41.mjs +670 -0
- package/dist/{chunk-integrations-globals.df0878f4.mjs → chunk-integrations-globals.6bb781c7.mjs} +6 -6
- package/dist/{chunk-runtime-chain.ce7f4b92.mjs → chunk-runtime-chain.68f305d0.mjs} +54 -135
- package/dist/{chunk-runtime-mocker.2f3cbfe5.mjs → chunk-runtime-mocker.1c207219.mjs} +28 -54
- package/dist/{chunk-utils-source-map.2556cba8.mjs → chunk-utils-source-map.f52527bc.mjs} +8 -22
- package/dist/{chunk-vite-node-externalize.105bc106.mjs → chunk-vite-node-externalize.1efbe319.mjs} +223 -206
- package/dist/{chunk-vite-node-utils.c0a0e1b3.mjs → chunk-vite-node-utils.4b58ae05.mjs} +16 -4
- package/dist/cli.mjs +9 -9
- package/dist/entry.mjs +6 -6
- package/dist/index.d.ts +161 -28
- package/dist/index.mjs +2 -2
- package/dist/node.d.ts +140 -20
- package/dist/node.mjs +11 -11
- package/dist/{vendor-entry.7ec02ea2.mjs → vendor-entry.2edaf3e0.mjs} +8 -419
- package/dist/worker.mjs +7 -6
- package/package.json +15 -10
- package/dist/chunk-defaults.dc6dc23d.mjs +0 -302
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
import { ViteDevServer, TransformResult, CommonServerOptions, UserConfig as UserConfig$1, Plugin as Plugin$1 } from 'vite';
|
|
2
|
+
import { Stats } from 'fs';
|
|
2
3
|
|
|
4
|
+
interface UpdatePayload {
|
|
5
|
+
type: 'update'
|
|
6
|
+
updates: Update[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Update {
|
|
10
|
+
type: 'js-update' | 'css-update'
|
|
11
|
+
path: string
|
|
12
|
+
acceptedPath: string
|
|
13
|
+
timestamp: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface PrunePayload {
|
|
17
|
+
type: 'prune'
|
|
18
|
+
paths: string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface FullReloadPayload {
|
|
22
|
+
type: 'full-reload'
|
|
23
|
+
path?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ErrorPayload {
|
|
27
|
+
type: 'error'
|
|
28
|
+
err: {
|
|
29
|
+
[name: string]: any
|
|
30
|
+
message: string
|
|
31
|
+
stack: string
|
|
32
|
+
id?: string
|
|
33
|
+
frame?: string
|
|
34
|
+
plugin?: string
|
|
35
|
+
pluginCode?: string
|
|
36
|
+
loc?: {
|
|
37
|
+
file?: string
|
|
38
|
+
line: number
|
|
39
|
+
column: number
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface CustomEventMap {
|
|
45
|
+
'vite:beforeUpdate': UpdatePayload
|
|
46
|
+
'vite:beforePrune': PrunePayload
|
|
47
|
+
'vite:beforeFullReload': FullReloadPayload
|
|
48
|
+
'vite:error': ErrorPayload
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type InferCustomEventPayload<T extends string> =
|
|
52
|
+
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
53
|
+
|
|
54
|
+
type ModuleNamespace = Record<string, any> & {
|
|
55
|
+
[Symbol.toStringTag]: 'Module'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface ViteHotContext {
|
|
59
|
+
readonly data: any
|
|
60
|
+
|
|
61
|
+
accept(): void
|
|
62
|
+
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
63
|
+
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
64
|
+
accept(
|
|
65
|
+
deps: readonly string[],
|
|
66
|
+
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
67
|
+
): void
|
|
68
|
+
|
|
69
|
+
acceptExports(exportNames: string | readonly string[]): void
|
|
70
|
+
acceptExports(
|
|
71
|
+
exportNames: string | readonly string[],
|
|
72
|
+
cb: (mod: ModuleNamespace | undefined) => void
|
|
73
|
+
): void
|
|
74
|
+
|
|
75
|
+
dispose(cb: (data: any) => void): void
|
|
76
|
+
decline(): void
|
|
77
|
+
invalidate(): void
|
|
78
|
+
|
|
79
|
+
on<T extends string>(
|
|
80
|
+
event: T,
|
|
81
|
+
cb: (payload: InferCustomEventPayload<T>) => void
|
|
82
|
+
): void
|
|
83
|
+
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
|
|
84
|
+
}
|
|
3
85
|
declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
4
86
|
normalizePath(fsPath: string): string;
|
|
5
87
|
set(fsPath: string, mod: Partial<ModuleCache>): this;
|
|
@@ -61,8 +143,10 @@ interface FetchResult {
|
|
|
61
143
|
externalize?: string;
|
|
62
144
|
map?: RawSourceMap;
|
|
63
145
|
}
|
|
146
|
+
declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
|
|
64
147
|
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
65
148
|
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
149
|
+
declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
|
|
66
150
|
interface ModuleCache {
|
|
67
151
|
promise?: Promise<any>;
|
|
68
152
|
exports?: any;
|
|
@@ -72,6 +156,7 @@ interface ViteNodeRunnerOptions {
|
|
|
72
156
|
root: string;
|
|
73
157
|
fetchModule: FetchFunction;
|
|
74
158
|
resolveId?: ResolveIdFunction;
|
|
159
|
+
createHotContext?: CreateHotContextFunction;
|
|
75
160
|
base?: string;
|
|
76
161
|
moduleCache?: ModuleCacheMap;
|
|
77
162
|
interopDefault?: boolean;
|
|
@@ -604,11 +689,12 @@ interface Test<ExtraContext = {}> extends TaskBase {
|
|
|
604
689
|
context: TestContext & ExtraContext;
|
|
605
690
|
}
|
|
606
691
|
declare type Task = Test | Suite | File;
|
|
607
|
-
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return
|
|
692
|
+
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
693
|
+
declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
608
694
|
interface SuiteHooks {
|
|
609
|
-
beforeAll: HookListener<[Suite | File],
|
|
695
|
+
beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
|
|
610
696
|
afterAll: HookListener<[Suite | File]>[];
|
|
611
|
-
beforeEach: HookListener<[TestContext, Suite],
|
|
697
|
+
beforeEach: HookListener<[TestContext, Suite], HookCleanupCallback>[];
|
|
612
698
|
afterEach: HookListener<[TestContext, Suite]>[];
|
|
613
699
|
}
|
|
614
700
|
interface TestContext {
|
|
@@ -684,7 +770,7 @@ interface SnapshotSummary {
|
|
|
684
770
|
updated: number;
|
|
685
771
|
}
|
|
686
772
|
|
|
687
|
-
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom';
|
|
773
|
+
declare type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
|
|
688
774
|
declare type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
|
|
689
775
|
|
|
690
776
|
interface EnvironmentOptions {
|
|
@@ -762,7 +848,7 @@ interface InlineConfig {
|
|
|
762
848
|
/**
|
|
763
849
|
* Running environment
|
|
764
850
|
*
|
|
765
|
-
* Supports 'node', 'jsdom', 'happy-dom'
|
|
851
|
+
* Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'
|
|
766
852
|
*
|
|
767
853
|
* @default 'node'
|
|
768
854
|
*/
|
|
@@ -987,6 +1073,13 @@ interface InlineConfig {
|
|
|
987
1073
|
* @default 5
|
|
988
1074
|
*/
|
|
989
1075
|
maxConcurrency?: number;
|
|
1076
|
+
/**
|
|
1077
|
+
* Options for configuring cache policy.
|
|
1078
|
+
* @default { dir: 'node_modules/.vitest' }
|
|
1079
|
+
*/
|
|
1080
|
+
cache?: false | {
|
|
1081
|
+
dir?: string;
|
|
1082
|
+
};
|
|
990
1083
|
}
|
|
991
1084
|
interface UserConfig extends InlineConfig {
|
|
992
1085
|
/**
|
|
@@ -1026,7 +1119,7 @@ interface UserConfig extends InlineConfig {
|
|
|
1026
1119
|
*/
|
|
1027
1120
|
shard?: string;
|
|
1028
1121
|
}
|
|
1029
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard'> {
|
|
1122
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard' | 'cache'> {
|
|
1030
1123
|
base?: string;
|
|
1031
1124
|
config?: string;
|
|
1032
1125
|
filters?: string[];
|
|
@@ -1041,6 +1134,9 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
1041
1134
|
index: number;
|
|
1042
1135
|
count: number;
|
|
1043
1136
|
};
|
|
1137
|
+
cache: {
|
|
1138
|
+
dir: string;
|
|
1139
|
+
} | false;
|
|
1044
1140
|
}
|
|
1045
1141
|
|
|
1046
1142
|
declare type VitestInlineConfig = InlineConfig;
|
|
@@ -1158,7 +1254,7 @@ declare class SnapshotState {
|
|
|
1158
1254
|
updated: number;
|
|
1159
1255
|
constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
|
|
1160
1256
|
markSnapshotsAsCheckedForTest(testName: string): void;
|
|
1161
|
-
private
|
|
1257
|
+
private _inferInlineSnapshotStack;
|
|
1162
1258
|
private _addSnapshot;
|
|
1163
1259
|
clear(): void;
|
|
1164
1260
|
save(): Promise<SaveStatus>;
|
|
@@ -1321,11 +1417,42 @@ interface WorkerPool {
|
|
|
1321
1417
|
close: () => Promise<void>;
|
|
1322
1418
|
}
|
|
1323
1419
|
|
|
1420
|
+
interface SuiteResultCache {
|
|
1421
|
+
failed: boolean;
|
|
1422
|
+
duration: number;
|
|
1423
|
+
}
|
|
1424
|
+
declare class ResultsCache {
|
|
1425
|
+
private cache;
|
|
1426
|
+
private cachePath;
|
|
1427
|
+
private version;
|
|
1428
|
+
private root;
|
|
1429
|
+
setConfig(root: string, config: ResolvedConfig['cache']): void;
|
|
1430
|
+
getResults(fsPath: string): SuiteResultCache | undefined;
|
|
1431
|
+
readFromCache(): Promise<void>;
|
|
1432
|
+
updateResults(files: File[]): void;
|
|
1433
|
+
removeFromCache(filepath: string): void;
|
|
1434
|
+
writeToCache(): Promise<void>;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
declare type FileStatsCache = Pick<Stats, 'size'>;
|
|
1438
|
+
declare class FilesStatsCache {
|
|
1439
|
+
cache: Map<string, FileStatsCache>;
|
|
1440
|
+
getStats(fsPath: string): FileStatsCache | undefined;
|
|
1441
|
+
updateStats(fsPath: string): Promise<void>;
|
|
1442
|
+
removeStats(fsPath: string): void;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1324
1445
|
declare class StateManager {
|
|
1325
1446
|
filesMap: Map<string, File>;
|
|
1326
1447
|
idMap: Map<string, Task>;
|
|
1327
1448
|
taskFileMap: WeakMap<Task, File>;
|
|
1328
1449
|
errorsSet: Set<unknown>;
|
|
1450
|
+
results: ResultsCache;
|
|
1451
|
+
stats: FilesStatsCache;
|
|
1452
|
+
getFileTestResults(id: string): SuiteResultCache | undefined;
|
|
1453
|
+
getFileStats(id: string): {
|
|
1454
|
+
size: number;
|
|
1455
|
+
} | undefined;
|
|
1329
1456
|
catchError(err: unknown, type: string): void;
|
|
1330
1457
|
clearErrors(): void;
|
|
1331
1458
|
getUnhandledErrors(): unknown[];
|
|
@@ -1368,7 +1495,7 @@ declare class Vitest {
|
|
|
1368
1495
|
start(filters?: string[]): Promise<void>;
|
|
1369
1496
|
private getTestDependencies;
|
|
1370
1497
|
filterTestsBySource(tests: string[]): Promise<string[]>;
|
|
1371
|
-
runFiles(
|
|
1498
|
+
runFiles(paths: string[]): Promise<void>;
|
|
1372
1499
|
rerunFiles(files?: string[], trigger?: string): Promise<void>;
|
|
1373
1500
|
changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
|
|
1374
1501
|
rerunFailed(): Promise<void>;
|
|
@@ -1406,7 +1533,6 @@ interface CliOptions extends UserConfig {
|
|
|
1406
1533
|
}
|
|
1407
1534
|
declare function startVitest(cliFilters: string[], options: CliOptions, viteOverrides?: UserConfig$1): Promise<boolean>;
|
|
1408
1535
|
|
|
1409
|
-
declare type Callback = (...args: any[]) => unknown;
|
|
1410
1536
|
interface ViteRunnerRequest {
|
|
1411
1537
|
(dep: string): any;
|
|
1412
1538
|
callstack: string[];
|
|
@@ -1414,15 +1540,13 @@ interface ViteRunnerRequest {
|
|
|
1414
1540
|
declare class VitestMocker {
|
|
1415
1541
|
options: ExecuteOptions;
|
|
1416
1542
|
private moduleCache;
|
|
1543
|
+
private request;
|
|
1417
1544
|
private static pendingIds;
|
|
1418
1545
|
private static spyModule?;
|
|
1419
|
-
|
|
1420
|
-
private root;
|
|
1421
|
-
private
|
|
1422
|
-
|
|
1423
|
-
get mockMap(): MockMap;
|
|
1424
|
-
on(event: string, cb: Callback): void;
|
|
1425
|
-
private emit;
|
|
1546
|
+
constructor(options: ExecuteOptions, moduleCache: ModuleCacheMap, request: ViteRunnerRequest);
|
|
1547
|
+
private get root();
|
|
1548
|
+
private get base();
|
|
1549
|
+
private get mockMap();
|
|
1426
1550
|
getSuiteFilepath(): string;
|
|
1427
1551
|
getMocks(): {
|
|
1428
1552
|
[x: string]: string | (() => unknown) | null;
|
|
@@ -1431,7 +1555,6 @@ declare class VitestMocker {
|
|
|
1431
1555
|
private resolveMocks;
|
|
1432
1556
|
private callFunctionMock;
|
|
1433
1557
|
getDependencyMock(dep: string): string | (() => unknown) | null;
|
|
1434
|
-
resolveDependency(dep: string): string;
|
|
1435
1558
|
normalizePath(path: string): string;
|
|
1436
1559
|
getFsPath(path: string, external: string | null): string;
|
|
1437
1560
|
resolveMockPath(mockPath: string, external: string | null): string | null;
|
|
@@ -1444,7 +1567,6 @@ declare class VitestMocker {
|
|
|
1444
1567
|
requestWithMock(dep: string): Promise<any>;
|
|
1445
1568
|
queueMock(id: string, importer: string, factory?: () => unknown): void;
|
|
1446
1569
|
queueUnmock(id: string, importer: string): void;
|
|
1447
|
-
withRequest(request: ViteRunnerRequest): VitestMocker;
|
|
1448
1570
|
}
|
|
1449
1571
|
|
|
1450
1572
|
interface ExecuteOptions extends ViteNodeRunnerOptions {
|
|
@@ -1452,8 +1574,6 @@ interface ExecuteOptions extends ViteNodeRunnerOptions {
|
|
|
1452
1574
|
}
|
|
1453
1575
|
declare class VitestRunner extends ViteNodeRunner {
|
|
1454
1576
|
options: ExecuteOptions;
|
|
1455
|
-
mocker: VitestMocker;
|
|
1456
|
-
entries: Set<string>;
|
|
1457
1577
|
constructor(options: ExecuteOptions);
|
|
1458
1578
|
prepareContext(context: Record<string, any>): Record<string, any> & {
|
|
1459
1579
|
__vite_ssr_import__: (dep: string) => Promise<any>;
|
package/dist/node.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.1efbe319.mjs';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.1c207219.mjs';
|
|
3
|
+
import './chunk-env-node.dc514f41.mjs';
|
|
4
|
+
import 'local-pkg';
|
|
5
|
+
import 'fs';
|
|
6
|
+
import 'module';
|
|
7
|
+
import 'url';
|
|
3
8
|
import './chunk-utils-global.79a8b1cc.mjs';
|
|
4
9
|
import 'tty';
|
|
5
|
-
import 'local-pkg';
|
|
6
10
|
import 'path';
|
|
7
11
|
import 'vite';
|
|
8
|
-
import 'url';
|
|
9
12
|
import 'process';
|
|
10
|
-
import '
|
|
11
|
-
import './chunk-defaults.dc6dc23d.mjs';
|
|
12
|
-
import 'module';
|
|
13
|
-
import './chunk-constants.7b9cfc82.mjs';
|
|
13
|
+
import './chunk-constants.511c6e9b.mjs';
|
|
14
14
|
import 'readline';
|
|
15
15
|
import 'os';
|
|
16
16
|
import 'util';
|
|
17
17
|
import 'stream';
|
|
18
18
|
import 'events';
|
|
19
19
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
20
|
-
import './chunk-vite-node-utils.
|
|
20
|
+
import './chunk-vite-node-utils.4b58ae05.mjs';
|
|
21
21
|
import 'vm';
|
|
22
22
|
import 'assert';
|
|
23
23
|
import 'debug';
|
|
24
24
|
import 'worker_threads';
|
|
25
|
-
import 'crypto';
|
|
26
25
|
import 'tinypool';
|
|
26
|
+
import 'crypto';
|
|
27
27
|
import 'perf_hooks';
|
|
28
|
-
import './chunk-utils-source-map.
|
|
28
|
+
import './chunk-utils-source-map.f52527bc.mjs';
|
|
29
29
|
import './vendor-index.e5dc6622.mjs';
|
|
30
30
|
import 'child_process';
|
|
31
31
|
import 'buffer';
|