vitest 0.14.2 → 0.15.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.aa092488.mjs → chunk-api-setup.ff687d0e.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.df0878f4.mjs} +7 -7
- package/dist/{chunk-runtime-chain.52571387.mjs → chunk-runtime-chain.ce7f4b92.mjs} +80 -60
- package/dist/{chunk-runtime-mocker.292c0e16.mjs → chunk-runtime-mocker.2f3cbfe5.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.db158bfb.mjs} +90 -157
- package/dist/{chunk-vite-node-utils.b9738a10.mjs → chunk-vite-node-utils.c0a0e1b3.mjs} +4 -4
- 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 +32 -4
- package/dist/index.mjs +4 -4
- package/dist/node.d.ts +28 -1
- package/dist/node.mjs +9 -8
- package/dist/{vendor-entry.ba490394.mjs → vendor-entry.7ec02ea2.mjs} +20 -12
- package/dist/worker.mjs +8 -7
- package/package.json +9 -8
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;
|
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.db158bfb.mjs';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.2f3cbfe5.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.c0a0e1b3.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.ce7f4b92.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.df0878f4.mjs')).registerApiGlobally();
|
|
441
442
|
}
|
|
442
443
|
function setupDefines(defines) {
|
|
443
444
|
for (const key in defines)
|
|
@@ -884,9 +885,15 @@ async function runTest(test) {
|
|
|
884
885
|
expectedAssertionsNumberErrorGen: null,
|
|
885
886
|
testPath: (_b = test.suite.file) == null ? void 0 : _b.filepath,
|
|
886
887
|
currentTestName: getFullName(test)
|
|
887
|
-
});
|
|
888
|
+
}, globalThis[GLOBAL_EXPECT]);
|
|
888
889
|
await getFn(test)();
|
|
889
|
-
const {
|
|
890
|
+
const {
|
|
891
|
+
assertionCalls,
|
|
892
|
+
expectedAssertionsNumber,
|
|
893
|
+
expectedAssertionsNumberErrorGen,
|
|
894
|
+
isExpectingAssertions,
|
|
895
|
+
isExpectingAssertionsError
|
|
896
|
+
} = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
|
|
890
897
|
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
891
898
|
throw expectedAssertionsNumberErrorGen();
|
|
892
899
|
if (isExpectingAssertions === true && assertionCalls === 0)
|
|
@@ -941,6 +948,7 @@ async function runSuite(suite) {
|
|
|
941
948
|
startTime: start
|
|
942
949
|
};
|
|
943
950
|
updateTask(suite);
|
|
951
|
+
const workerState = getWorkerState();
|
|
944
952
|
if (suite.mode === "skip") {
|
|
945
953
|
suite.result.state = "skip";
|
|
946
954
|
} else if (suite.mode === "todo") {
|
|
@@ -950,7 +958,8 @@ async function runSuite(suite) {
|
|
|
950
958
|
const beforeAllCleanups = await callSuiteHook(suite, suite, "beforeAll", [suite]);
|
|
951
959
|
for (const tasksGroup of partitionSuiteChildren(suite)) {
|
|
952
960
|
if (tasksGroup[0].concurrent === true) {
|
|
953
|
-
|
|
961
|
+
const mutex = pLimit(workerState.config.maxConcurrency);
|
|
962
|
+
await Promise.all(tasksGroup.map((c) => mutex(() => runSuiteChild(c))));
|
|
954
963
|
} else {
|
|
955
964
|
for (const c of tasksGroup)
|
|
956
965
|
await runSuiteChild(c);
|
|
@@ -964,7 +973,6 @@ async function runSuite(suite) {
|
|
|
964
973
|
}
|
|
965
974
|
}
|
|
966
975
|
suite.result.duration = now() - start;
|
|
967
|
-
const workerState = getWorkerState();
|
|
968
976
|
if (workerState.config.logHeapUsage)
|
|
969
977
|
suite.result.heap = process.memoryUsage().heapUsed;
|
|
970
978
|
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.c0a0e1b3.mjs';
|
|
3
|
+
import { d as distDir } from './chunk-constants.7b9cfc82.mjs';
|
|
4
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.2f3cbfe5.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.0",
|
|
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
87
|
"tinyspy": "^0.3.2",
|
|
87
|
-
"vite": "^2.9.
|
|
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.0",
|
|
100
100
|
"birpc": "^0.2.3",
|
|
101
101
|
"c8": "^7.11.3",
|
|
102
102
|
"cac": "^6.7.12",
|
|
@@ -114,17 +114,18 @@
|
|
|
114
114
|
"micromatch": "^4.0.5",
|
|
115
115
|
"mlly": "^0.5.2",
|
|
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
120
|
"pkg-types": "^0.3.2",
|
|
120
121
|
"pretty-format": "^27.5.1",
|
|
121
122
|
"prompts": "^2.4.2",
|
|
122
|
-
"rollup": "^2.75.
|
|
123
|
+
"rollup": "^2.75.6",
|
|
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.3",
|
|
127
|
+
"vite-node": "0.15.0",
|
|
128
|
+
"ws": "^8.8.0"
|
|
128
129
|
},
|
|
129
130
|
"scripts": {
|
|
130
131
|
"build": "rimraf dist && rollup -c",
|