vitest 0.14.2 → 0.15.2
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.aa092488.mjs → chunk-api-setup.8cd5e92a.mjs} +44 -37
- package/dist/{chunk-constants.da1921b9.mjs → chunk-constants.7b9cfc82.mjs} +1 -1
- package/dist/{chunk-defaults.45dc5e3d.mjs → chunk-defaults.dc6dc23d.mjs} +142 -3
- package/dist/{chunk-integrations-globals.edcc399b.mjs → chunk-integrations-globals.d0c363a6.mjs} +7 -7
- package/dist/{chunk-runtime-chain.52571387.mjs → chunk-runtime-chain.7103058b.mjs} +89 -62
- package/dist/{chunk-runtime-mocker.292c0e16.mjs → chunk-runtime-mocker.d3ca0a4e.mjs} +3 -3
- package/dist/{chunk-runtime-rpc.bcd3613c.mjs → chunk-runtime-rpc.5e78af38.mjs} +1 -1
- package/dist/{chunk-utils-global.2684ee9f.mjs → chunk-utils-global.79a8b1cc.mjs} +1 -1
- package/dist/{chunk-utils-source-map.790e5c11.mjs → chunk-utils-source-map.2556cba8.mjs} +1 -1
- package/dist/{chunk-vite-node-externalize.6b27b039.mjs → chunk-vite-node-externalize.0ec89ad1.mjs} +97 -163
- package/dist/{chunk-vite-node-utils.b9738a10.mjs → chunk-vite-node-utils.1bbdb2c1.mjs} +5 -5
- package/dist/cli.mjs +10 -9
- package/dist/config.cjs +5 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.mjs +5 -1
- package/dist/entry.mjs +6 -6
- package/dist/index.d.ts +35 -11
- package/dist/index.mjs +4 -4
- package/dist/node.d.ts +29 -2
- package/dist/node.mjs +9 -8
- package/dist/{vendor-entry.ba490394.mjs → vendor-entry.efeeaa5c.mjs} +23 -13
- package/dist/worker.mjs +8 -7
- package/package.json +12 -11
package/dist/index.d.ts
CHANGED
|
@@ -1152,6 +1152,22 @@ interface InlineConfig {
|
|
|
1152
1152
|
* Return `false` to ignore the log.
|
|
1153
1153
|
*/
|
|
1154
1154
|
onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
|
|
1155
|
+
/**
|
|
1156
|
+
* Indicates if CSS files should be processed.
|
|
1157
|
+
*
|
|
1158
|
+
* When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
|
|
1159
|
+
*
|
|
1160
|
+
* @default { include: [/\.module\./] }
|
|
1161
|
+
*/
|
|
1162
|
+
css?: boolean | {
|
|
1163
|
+
include?: RegExp | RegExp[];
|
|
1164
|
+
exclude?: RegExp | RegExp[];
|
|
1165
|
+
};
|
|
1166
|
+
/**
|
|
1167
|
+
* A number of tests that are allowed to run at the same time marked with `test.concurrent`.
|
|
1168
|
+
* @default 5
|
|
1169
|
+
*/
|
|
1170
|
+
maxConcurrency?: number;
|
|
1155
1171
|
}
|
|
1156
1172
|
interface UserConfig extends InlineConfig {
|
|
1157
1173
|
/**
|
|
@@ -1183,8 +1199,15 @@ interface UserConfig extends InlineConfig {
|
|
|
1183
1199
|
* @default false
|
|
1184
1200
|
*/
|
|
1185
1201
|
changed?: boolean | string;
|
|
1202
|
+
/**
|
|
1203
|
+
* Test suite shard to execute in a format of <index>/<count>.
|
|
1204
|
+
* Will divide tests into a `count` numbers, and run only the `indexed` part.
|
|
1205
|
+
* Cannot be used with enabled watch.
|
|
1206
|
+
* @example --shard=2/3
|
|
1207
|
+
*/
|
|
1208
|
+
shard?: string;
|
|
1186
1209
|
}
|
|
1187
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath'> {
|
|
1210
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard'> {
|
|
1188
1211
|
base?: string;
|
|
1189
1212
|
config?: string;
|
|
1190
1213
|
filters?: string[];
|
|
@@ -1195,6 +1218,10 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
1195
1218
|
reporters: (Reporter | BuiltinReporters)[];
|
|
1196
1219
|
defines: Record<string, any>;
|
|
1197
1220
|
api?: ApiConfig;
|
|
1221
|
+
shard?: {
|
|
1222
|
+
index: number;
|
|
1223
|
+
count: number;
|
|
1224
|
+
};
|
|
1198
1225
|
}
|
|
1199
1226
|
|
|
1200
1227
|
declare type VitestInlineConfig = InlineConfig;
|
|
@@ -1312,7 +1339,7 @@ declare class SnapshotState {
|
|
|
1312
1339
|
updated: number;
|
|
1313
1340
|
constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
|
|
1314
1341
|
markSnapshotsAsCheckedForTest(testName: string): void;
|
|
1315
|
-
private
|
|
1342
|
+
private _inferInlineSnapshotStack;
|
|
1316
1343
|
private _addSnapshot;
|
|
1317
1344
|
clear(): void;
|
|
1318
1345
|
save(): Promise<SaveStatus>;
|
|
@@ -1471,7 +1498,8 @@ declare type BirpcReturn<RemoteFunctions> = {
|
|
|
1471
1498
|
};
|
|
1472
1499
|
|
|
1473
1500
|
interface WorkerContext {
|
|
1474
|
-
|
|
1501
|
+
workerId: number;
|
|
1502
|
+
poolId: number;
|
|
1475
1503
|
port: MessagePort;
|
|
1476
1504
|
config: ResolvedConfig;
|
|
1477
1505
|
files: string[];
|
|
@@ -1555,10 +1583,10 @@ interface SpyInstanceFn<TArgs extends any[] = any, TReturns = any> extends SpyIn
|
|
|
1555
1583
|
new (...args: TArgs): TReturns;
|
|
1556
1584
|
}
|
|
1557
1585
|
declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? SpyInstanceFn<ConstructorParameters<T>, R> : T;
|
|
1558
|
-
declare type MockedFunction<T extends Procedure> =
|
|
1586
|
+
declare type MockedFunction<T extends Procedure> = SpyInstanceFn<Parameters<T>, ReturnType<T>> & {
|
|
1559
1587
|
[K in keyof T]: T[K];
|
|
1560
1588
|
};
|
|
1561
|
-
declare type MockedFunctionDeep<T extends Procedure> =
|
|
1589
|
+
declare type MockedFunctionDeep<T extends Procedure> = SpyInstanceFn<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
|
|
1562
1590
|
declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
1563
1591
|
[K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
|
|
1564
1592
|
} & {
|
|
@@ -1572,10 +1600,6 @@ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
|
1572
1600
|
declare type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
1573
1601
|
declare type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
1574
1602
|
declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
|
|
1575
|
-
interface MockWithArgs<T extends Procedure> extends SpyInstanceFn<Parameters<T>, ReturnType<T>> {
|
|
1576
|
-
new (...args: T extends new (...args: any) => any ? ConstructorParameters<T> : never): T;
|
|
1577
|
-
(...args: Parameters<T>): ReturnType<T>;
|
|
1578
|
-
}
|
|
1579
1603
|
declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
|
|
1580
1604
|
declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
|
|
1581
1605
|
declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends (...args: infer A) => infer R | (new (...args: infer A) => infer R) ? SpyInstance<A, R> : never;
|
|
@@ -1617,7 +1641,7 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
|
|
|
1617
1641
|
declare function isFirstRun(): boolean;
|
|
1618
1642
|
|
|
1619
1643
|
declare function createExpect(test?: Test): Vi.ExpectStatic;
|
|
1620
|
-
declare const
|
|
1644
|
+
declare const globalExpect: Vi.ExpectStatic;
|
|
1621
1645
|
|
|
1622
1646
|
declare class VitestUtils {
|
|
1623
1647
|
private _timers;
|
|
@@ -1737,4 +1761,4 @@ interface WebSocketHandlers {
|
|
|
1737
1761
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog'> {
|
|
1738
1762
|
}
|
|
1739
1763
|
|
|
1740
|
-
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyContext, SpyInstance, SpyInstanceFn, 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, expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
|
|
1764
|
+
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyContext, SpyInstance, SpyInstanceFn, 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,13 @@
|
|
|
1
|
-
export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.
|
|
1
|
+
export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.7103058b.mjs';
|
|
2
2
|
export { assert, default as chai, should } from 'chai';
|
|
3
3
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
4
|
-
import './chunk-runtime-rpc.
|
|
5
|
-
import './chunk-utils-global.
|
|
4
|
+
import './chunk-runtime-rpc.5e78af38.mjs';
|
|
5
|
+
import './chunk-utils-global.79a8b1cc.mjs';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
8
|
import 'path';
|
|
9
9
|
import 'fs';
|
|
10
|
-
import './chunk-utils-source-map.
|
|
10
|
+
import './chunk-utils-source-map.2556cba8.mjs';
|
|
11
11
|
import './chunk-integrations-spy.674b628e.mjs';
|
|
12
12
|
import 'tinyspy';
|
|
13
13
|
import 'util';
|
package/dist/node.d.ts
CHANGED
|
@@ -971,6 +971,22 @@ interface InlineConfig {
|
|
|
971
971
|
* Return `false` to ignore the log.
|
|
972
972
|
*/
|
|
973
973
|
onConsoleLog?: (log: string, type: 'stdout' | 'stderr') => false | void;
|
|
974
|
+
/**
|
|
975
|
+
* Indicates if CSS files should be processed.
|
|
976
|
+
*
|
|
977
|
+
* When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.
|
|
978
|
+
*
|
|
979
|
+
* @default { include: [/\.module\./] }
|
|
980
|
+
*/
|
|
981
|
+
css?: boolean | {
|
|
982
|
+
include?: RegExp | RegExp[];
|
|
983
|
+
exclude?: RegExp | RegExp[];
|
|
984
|
+
};
|
|
985
|
+
/**
|
|
986
|
+
* A number of tests that are allowed to run at the same time marked with `test.concurrent`.
|
|
987
|
+
* @default 5
|
|
988
|
+
*/
|
|
989
|
+
maxConcurrency?: number;
|
|
974
990
|
}
|
|
975
991
|
interface UserConfig extends InlineConfig {
|
|
976
992
|
/**
|
|
@@ -1002,8 +1018,15 @@ interface UserConfig extends InlineConfig {
|
|
|
1002
1018
|
* @default false
|
|
1003
1019
|
*/
|
|
1004
1020
|
changed?: boolean | string;
|
|
1021
|
+
/**
|
|
1022
|
+
* Test suite shard to execute in a format of <index>/<count>.
|
|
1023
|
+
* Will divide tests into a `count` numbers, and run only the `indexed` part.
|
|
1024
|
+
* Cannot be used with enabled watch.
|
|
1025
|
+
* @example --shard=2/3
|
|
1026
|
+
*/
|
|
1027
|
+
shard?: string;
|
|
1005
1028
|
}
|
|
1006
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath'> {
|
|
1029
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'shard'> {
|
|
1007
1030
|
base?: string;
|
|
1008
1031
|
config?: string;
|
|
1009
1032
|
filters?: string[];
|
|
@@ -1014,6 +1037,10 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
|
|
|
1014
1037
|
reporters: (Reporter | BuiltinReporters)[];
|
|
1015
1038
|
defines: Record<string, any>;
|
|
1016
1039
|
api?: ApiConfig;
|
|
1040
|
+
shard?: {
|
|
1041
|
+
index: number;
|
|
1042
|
+
count: number;
|
|
1043
|
+
};
|
|
1017
1044
|
}
|
|
1018
1045
|
|
|
1019
1046
|
declare type VitestInlineConfig = InlineConfig;
|
|
@@ -1131,7 +1158,7 @@ declare class SnapshotState {
|
|
|
1131
1158
|
updated: number;
|
|
1132
1159
|
constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
|
|
1133
1160
|
markSnapshotsAsCheckedForTest(testName: string): void;
|
|
1134
|
-
private
|
|
1161
|
+
private _inferInlineSnapshotStack;
|
|
1135
1162
|
private _addSnapshot;
|
|
1136
1163
|
clear(): void;
|
|
1137
1164
|
save(): Promise<SaveStatus>;
|
package/dist/node.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.
|
|
3
|
-
import './chunk-utils-global.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.0ec89ad1.mjs';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.d3ca0a4e.mjs';
|
|
3
|
+
import './chunk-utils-global.79a8b1cc.mjs';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
@@ -8,23 +8,24 @@ import 'vite';
|
|
|
8
8
|
import 'url';
|
|
9
9
|
import 'process';
|
|
10
10
|
import 'fs';
|
|
11
|
-
import './chunk-
|
|
11
|
+
import './chunk-defaults.dc6dc23d.mjs';
|
|
12
|
+
import 'module';
|
|
13
|
+
import './chunk-constants.7b9cfc82.mjs';
|
|
12
14
|
import 'readline';
|
|
13
15
|
import 'os';
|
|
14
16
|
import 'util';
|
|
15
17
|
import 'stream';
|
|
16
18
|
import 'events';
|
|
17
19
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
18
|
-
import './chunk-vite-node-utils.
|
|
19
|
-
import 'module';
|
|
20
|
+
import './chunk-vite-node-utils.1bbdb2c1.mjs';
|
|
20
21
|
import 'vm';
|
|
21
22
|
import 'assert';
|
|
22
23
|
import 'debug';
|
|
23
|
-
import './chunk-defaults.45dc5e3d.mjs';
|
|
24
24
|
import 'worker_threads';
|
|
25
|
+
import 'crypto';
|
|
25
26
|
import 'tinypool';
|
|
26
27
|
import 'perf_hooks';
|
|
27
|
-
import './chunk-utils-source-map.
|
|
28
|
+
import './chunk-utils-source-map.2556cba8.mjs';
|
|
28
29
|
import './vendor-index.e5dc6622.mjs';
|
|
29
30
|
import 'child_process';
|
|
30
31
|
import 'buffer';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import {
|
|
2
|
+
import { t as isNode, a as getWorkerState, h as safeClearTimeout, f as safeSetTimeout, C as toArray, N as deepClone, L as getType, q as relative, O as partitionSuiteChildren, P as hasTests, v as hasFailed, e as getFullName, r as resetModules } from './chunk-utils-global.79a8b1cc.mjs';
|
|
3
3
|
import { importModule } from 'local-pkg';
|
|
4
|
-
import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as
|
|
4
|
+
import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as globalExpect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, G as GLOBAL_EXPECT, z as getFn, A as getState } from './chunk-runtime-chain.7103058b.mjs';
|
|
5
5
|
import chai, { assert, should, util } from 'chai';
|
|
6
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
7
|
-
import { t as takeCoverage } from './chunk-defaults.
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
|
|
7
|
+
import { t as takeCoverage, p as pLimit } from './chunk-defaults.dc6dc23d.mjs';
|
|
8
8
|
import { format } from 'util';
|
|
9
|
-
import { s as stringify } from './chunk-utils-source-map.
|
|
9
|
+
import { s as stringify } from './chunk-utils-source-map.2556cba8.mjs';
|
|
10
10
|
|
|
11
11
|
var index = /*#__PURE__*/Object.freeze({
|
|
12
12
|
__proto__: null,
|
|
@@ -25,7 +25,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
25
25
|
should: should,
|
|
26
26
|
createExpect: createExpect,
|
|
27
27
|
chai: chai,
|
|
28
|
-
expect:
|
|
28
|
+
expect: globalExpect,
|
|
29
29
|
vitest: vitest,
|
|
30
30
|
vi: vi,
|
|
31
31
|
getRunningMode: getRunningMode,
|
|
@@ -286,7 +286,7 @@ function getWindowKeys(global, win) {
|
|
|
286
286
|
function isClassLikeName(name) {
|
|
287
287
|
return name[0] === name[0].toUpperCase();
|
|
288
288
|
}
|
|
289
|
-
function populateGlobal(global, win, options) {
|
|
289
|
+
function populateGlobal(global, win, options = {}) {
|
|
290
290
|
const { bindFunctions = false } = options;
|
|
291
291
|
const keys = getWindowKeys(global, win);
|
|
292
292
|
const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
|
|
@@ -310,6 +310,7 @@ function populateGlobal(global, win, options) {
|
|
|
310
310
|
global.window = global;
|
|
311
311
|
global.self = global;
|
|
312
312
|
global.top = global;
|
|
313
|
+
global.parent = global;
|
|
313
314
|
if (global.global)
|
|
314
315
|
global.global = global;
|
|
315
316
|
skipKeys.forEach((k) => keys.add(k));
|
|
@@ -437,7 +438,7 @@ async function setupGlobalEnv(config) {
|
|
|
437
438
|
if (isNode)
|
|
438
439
|
await setupConsoleLogSpy();
|
|
439
440
|
if (config.globals)
|
|
440
|
-
(await import('./chunk-integrations-globals.
|
|
441
|
+
(await import('./chunk-integrations-globals.d0c363a6.mjs')).registerApiGlobally();
|
|
441
442
|
}
|
|
442
443
|
function setupDefines(defines) {
|
|
443
444
|
for (const key in defines)
|
|
@@ -857,8 +858,10 @@ async function sendTasksUpdate() {
|
|
|
857
858
|
}
|
|
858
859
|
async function runTest(test) {
|
|
859
860
|
var _a, _b;
|
|
860
|
-
if (test.mode !== "run")
|
|
861
|
+
if (test.mode !== "run") {
|
|
862
|
+
getSnapshotClient().skipTestSnapshots(test);
|
|
861
863
|
return;
|
|
864
|
+
}
|
|
862
865
|
if (((_a = test.result) == null ? void 0 : _a.state) === "fail") {
|
|
863
866
|
updateTask(test);
|
|
864
867
|
return;
|
|
@@ -884,9 +887,15 @@ async function runTest(test) {
|
|
|
884
887
|
expectedAssertionsNumberErrorGen: null,
|
|
885
888
|
testPath: (_b = test.suite.file) == null ? void 0 : _b.filepath,
|
|
886
889
|
currentTestName: getFullName(test)
|
|
887
|
-
});
|
|
890
|
+
}, globalThis[GLOBAL_EXPECT]);
|
|
888
891
|
await getFn(test)();
|
|
889
|
-
const {
|
|
892
|
+
const {
|
|
893
|
+
assertionCalls,
|
|
894
|
+
expectedAssertionsNumber,
|
|
895
|
+
expectedAssertionsNumberErrorGen,
|
|
896
|
+
isExpectingAssertions,
|
|
897
|
+
isExpectingAssertionsError
|
|
898
|
+
} = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
890
899
|
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
891
900
|
throw expectedAssertionsNumberErrorGen();
|
|
892
901
|
if (isExpectingAssertions === true && assertionCalls === 0)
|
|
@@ -941,6 +950,7 @@ async function runSuite(suite) {
|
|
|
941
950
|
startTime: start
|
|
942
951
|
};
|
|
943
952
|
updateTask(suite);
|
|
953
|
+
const workerState = getWorkerState();
|
|
944
954
|
if (suite.mode === "skip") {
|
|
945
955
|
suite.result.state = "skip";
|
|
946
956
|
} else if (suite.mode === "todo") {
|
|
@@ -950,7 +960,8 @@ async function runSuite(suite) {
|
|
|
950
960
|
const beforeAllCleanups = await callSuiteHook(suite, suite, "beforeAll", [suite]);
|
|
951
961
|
for (const tasksGroup of partitionSuiteChildren(suite)) {
|
|
952
962
|
if (tasksGroup[0].concurrent === true) {
|
|
953
|
-
|
|
963
|
+
const mutex = pLimit(workerState.config.maxConcurrency);
|
|
964
|
+
await Promise.all(tasksGroup.map((c) => mutex(() => runSuiteChild(c))));
|
|
954
965
|
} else {
|
|
955
966
|
for (const c of tasksGroup)
|
|
956
967
|
await runSuiteChild(c);
|
|
@@ -964,7 +975,6 @@ async function runSuite(suite) {
|
|
|
964
975
|
}
|
|
965
976
|
}
|
|
966
977
|
suite.result.duration = now() - start;
|
|
967
|
-
const workerState = getWorkerState();
|
|
968
978
|
if (workerState.config.logHeapUsage)
|
|
969
979
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
970
980
|
if (suite.mode === "run") {
|
package/dist/worker.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.
|
|
3
|
-
import { d as distDir } from './chunk-constants.
|
|
4
|
-
import { e as executeInViteNode } from './chunk-runtime-mocker.
|
|
5
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
1
|
+
import { m as resolve, a as getWorkerState } from './chunk-utils-global.79a8b1cc.mjs';
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.1bbdb2c1.mjs';
|
|
3
|
+
import { d as distDir } from './chunk-constants.7b9cfc82.mjs';
|
|
4
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.d3ca0a4e.mjs';
|
|
5
|
+
import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
8
|
import 'path';
|
|
@@ -55,8 +55,9 @@ async function startViteNode(ctx) {
|
|
|
55
55
|
function init(ctx) {
|
|
56
56
|
if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
|
|
57
57
|
throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
|
|
58
|
-
const { config, port,
|
|
59
|
-
process.env.VITEST_WORKER_ID = String(
|
|
58
|
+
const { config, port, workerId, poolId } = ctx;
|
|
59
|
+
process.env.VITEST_WORKER_ID = String(workerId);
|
|
60
|
+
process.env.VITEST_POOL_ID = String(poolId);
|
|
60
61
|
globalThis.__vitest_worker__ = {
|
|
61
62
|
ctx,
|
|
62
63
|
moduleCache,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -79,12 +79,13 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@types/chai": "^4.3.1",
|
|
81
81
|
"@types/chai-subset": "^1.3.3",
|
|
82
|
+
"@types/node": "*",
|
|
82
83
|
"chai": "^4.3.6",
|
|
83
84
|
"debug": "^4.3.4",
|
|
84
85
|
"local-pkg": "^0.4.1",
|
|
85
86
|
"tinypool": "^0.1.3",
|
|
86
|
-
"tinyspy": "^0.3.
|
|
87
|
-
"vite": "^2.9.
|
|
87
|
+
"tinyspy": "^0.3.3",
|
|
88
|
+
"vite": "^2.9.12"
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@antfu/install-pkg": "^0.1.0",
|
|
@@ -93,10 +94,9 @@
|
|
|
93
94
|
"@types/jsdom": "^16.2.14",
|
|
94
95
|
"@types/micromatch": "^4.0.2",
|
|
95
96
|
"@types/natural-compare": "^1.4.1",
|
|
96
|
-
"@types/node": "^17.0.35",
|
|
97
97
|
"@types/prompts": "^2.4.0",
|
|
98
98
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
99
|
-
"@vitest/ui": "0.
|
|
99
|
+
"@vitest/ui": "0.15.2",
|
|
100
100
|
"birpc": "^0.2.3",
|
|
101
101
|
"c8": "^7.11.3",
|
|
102
102
|
"cac": "^6.7.12",
|
|
@@ -112,19 +112,20 @@
|
|
|
112
112
|
"log-update": "^5.0.1",
|
|
113
113
|
"magic-string": "^0.26.2",
|
|
114
114
|
"micromatch": "^4.0.5",
|
|
115
|
-
"mlly": "^0.5.
|
|
115
|
+
"mlly": "^0.5.3",
|
|
116
116
|
"natural-compare": "^1.4.0",
|
|
117
|
+
"p-limit": "^4.0.0",
|
|
117
118
|
"pathe": "^0.2.0",
|
|
118
119
|
"picocolors": "^1.0.0",
|
|
119
|
-
"pkg-types": "^0.3.
|
|
120
|
+
"pkg-types": "^0.3.3",
|
|
120
121
|
"pretty-format": "^27.5.1",
|
|
121
122
|
"prompts": "^2.4.2",
|
|
122
|
-
"rollup": "^2.75.
|
|
123
|
+
"rollup": "^2.75.7",
|
|
123
124
|
"source-map-js": "^1.0.2",
|
|
124
125
|
"strip-ansi": "^7.0.1",
|
|
125
|
-
"typescript": "^4.7.
|
|
126
|
-
"vite-node": "0.
|
|
127
|
-
"ws": "^8.
|
|
126
|
+
"typescript": "^4.7.4",
|
|
127
|
+
"vite-node": "0.15.2",
|
|
128
|
+
"ws": "^8.8.0"
|
|
128
129
|
},
|
|
129
130
|
"scripts": {
|
|
130
131
|
"build": "rimraf dist && rollup -c",
|