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/{chunk-vite-node-externalize.6b27b039.mjs → chunk-vite-node-externalize.db158bfb.mjs}
RENAMED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { j as join,
|
|
1
|
+
import { j as join, l as basename, d as dirname, m as resolve, s as slash$2, A as AggregateErrorPonyfill, p as picocolors, o as isAbsolute, q as relative, t as isNode, u as getTests, e as getFullName, v as hasFailed, x as hasFailedSnapshot, y as getSuites, z as safeSetInterval, B as safeClearInterval, f as safeSetTimeout, C as toArray$1, D as normalize, n as noop$1, h as safeClearTimeout, E as deepMerge, F as toNamespacedPath, g as getCallLastIndex, k as notNullish, G as ensurePackageInstalled, H as stdout } from './chunk-utils-global.79a8b1cc.mjs';
|
|
2
2
|
import { createServer, mergeConfig } from 'vite';
|
|
3
3
|
import path$a from 'path';
|
|
4
4
|
import url, { fileURLToPath, pathToFileURL } from 'url';
|
|
5
5
|
import process$1 from 'process';
|
|
6
6
|
import fs$8, { promises, existsSync, readFileSync } from 'fs';
|
|
7
|
-
import {
|
|
7
|
+
import { p as pLimit, c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.dc6dc23d.mjs';
|
|
8
|
+
import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.7b9cfc82.mjs';
|
|
8
9
|
import readline from 'readline';
|
|
9
10
|
import require$$0, { cpus, hostname, constants as constants$5 } from 'os';
|
|
10
11
|
import require$$0$1 from 'util';
|
|
11
12
|
import require$$0$2 from 'stream';
|
|
12
13
|
import require$$2 from 'events';
|
|
13
14
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
14
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
15
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.c0a0e1b3.mjs';
|
|
15
16
|
import createDebug from 'debug';
|
|
16
|
-
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.45dc5e3d.mjs';
|
|
17
17
|
import { MessageChannel } from 'worker_threads';
|
|
18
|
+
import { createHash } from 'crypto';
|
|
18
19
|
import { Tinypool } from 'tinypool';
|
|
19
20
|
import { performance } from 'perf_hooks';
|
|
20
|
-
import { c as stripAnsi, d as stringWidth, e as ansiStyles, h as sliceAnsi, i as cliTruncate, b as parseStacktrace, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.
|
|
21
|
+
import { c as stripAnsi, d as stringWidth, e as ansiStyles, h as sliceAnsi, i as cliTruncate, b as parseStacktrace, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.2556cba8.mjs';
|
|
21
22
|
import { o as onetime$1, s as signalExit, m as mergeStream, g as getStream, c as crossSpawn } from './vendor-index.e5dc6622.mjs';
|
|
22
23
|
import { resolveModule } from 'local-pkg';
|
|
23
24
|
import { Buffer } from 'buffer';
|
|
@@ -25,142 +26,7 @@ import childProcess from 'child_process';
|
|
|
25
26
|
import MagicString from './chunk-magic-string.efe26975.mjs';
|
|
26
27
|
import { p as prompts } from './vendor-index.98e769c1.mjs';
|
|
27
28
|
|
|
28
|
-
var version = "0.
|
|
29
|
-
|
|
30
|
-
/*
|
|
31
|
-
How it works:
|
|
32
|
-
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
class Node {
|
|
36
|
-
value;
|
|
37
|
-
next;
|
|
38
|
-
|
|
39
|
-
constructor(value) {
|
|
40
|
-
this.value = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class Queue {
|
|
45
|
-
#head;
|
|
46
|
-
#tail;
|
|
47
|
-
#size;
|
|
48
|
-
|
|
49
|
-
constructor() {
|
|
50
|
-
this.clear();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
enqueue(value) {
|
|
54
|
-
const node = new Node(value);
|
|
55
|
-
|
|
56
|
-
if (this.#head) {
|
|
57
|
-
this.#tail.next = node;
|
|
58
|
-
this.#tail = node;
|
|
59
|
-
} else {
|
|
60
|
-
this.#head = node;
|
|
61
|
-
this.#tail = node;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
this.#size++;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
dequeue() {
|
|
68
|
-
const current = this.#head;
|
|
69
|
-
if (!current) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
this.#head = this.#head.next;
|
|
74
|
-
this.#size--;
|
|
75
|
-
return current.value;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
clear() {
|
|
79
|
-
this.#head = undefined;
|
|
80
|
-
this.#tail = undefined;
|
|
81
|
-
this.#size = 0;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
get size() {
|
|
85
|
-
return this.#size;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
* [Symbol.iterator]() {
|
|
89
|
-
let current = this.#head;
|
|
90
|
-
|
|
91
|
-
while (current) {
|
|
92
|
-
yield current.value;
|
|
93
|
-
current = current.next;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function pLimit(concurrency) {
|
|
99
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
100
|
-
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const queue = new Queue();
|
|
104
|
-
let activeCount = 0;
|
|
105
|
-
|
|
106
|
-
const next = () => {
|
|
107
|
-
activeCount--;
|
|
108
|
-
|
|
109
|
-
if (queue.size > 0) {
|
|
110
|
-
queue.dequeue()();
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const run = async (fn, resolve, args) => {
|
|
115
|
-
activeCount++;
|
|
116
|
-
|
|
117
|
-
const result = (async () => fn(...args))();
|
|
118
|
-
|
|
119
|
-
resolve(result);
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
await result;
|
|
123
|
-
} catch {}
|
|
124
|
-
|
|
125
|
-
next();
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const enqueue = (fn, resolve, args) => {
|
|
129
|
-
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
|
130
|
-
|
|
131
|
-
(async () => {
|
|
132
|
-
// This function needs to wait until the next microtask before comparing
|
|
133
|
-
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
134
|
-
// when the run function is dequeued and called. The comparison in the if-statement
|
|
135
|
-
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
136
|
-
await Promise.resolve();
|
|
137
|
-
|
|
138
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
139
|
-
queue.dequeue()();
|
|
140
|
-
}
|
|
141
|
-
})();
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const generator = (fn, ...args) => new Promise(resolve => {
|
|
145
|
-
enqueue(fn, resolve, args);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
Object.defineProperties(generator, {
|
|
149
|
-
activeCount: {
|
|
150
|
-
get: () => activeCount,
|
|
151
|
-
},
|
|
152
|
-
pendingCount: {
|
|
153
|
-
get: () => queue.size,
|
|
154
|
-
},
|
|
155
|
-
clearQueue: {
|
|
156
|
-
value: () => {
|
|
157
|
-
queue.clear();
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
return generator;
|
|
163
|
-
}
|
|
29
|
+
var version = "0.15.0";
|
|
164
30
|
|
|
165
31
|
class EndError extends Error {
|
|
166
32
|
constructor(value) {
|
|
@@ -188,7 +54,7 @@ async function pLocate(
|
|
|
188
54
|
{
|
|
189
55
|
concurrency = Number.POSITIVE_INFINITY,
|
|
190
56
|
preserveOrder = true,
|
|
191
|
-
},
|
|
57
|
+
} = {},
|
|
192
58
|
) {
|
|
193
59
|
const limit = pLimit(concurrency);
|
|
194
60
|
|
|
@@ -255,7 +121,7 @@ const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath)
|
|
|
255
121
|
|
|
256
122
|
const findUpStop = Symbol('findUpStop');
|
|
257
123
|
|
|
258
|
-
async function findUpMultiple(name, options) {
|
|
124
|
+
async function findUpMultiple(name, options = {}) {
|
|
259
125
|
let directory = path$a.resolve(toPath(options.cwd) || '');
|
|
260
126
|
const {root} = path$a.parse(directory);
|
|
261
127
|
const stopAt = path$a.resolve(directory, options.stopAt || root);
|
|
@@ -299,7 +165,7 @@ async function findUpMultiple(name, options) {
|
|
|
299
165
|
return matches;
|
|
300
166
|
}
|
|
301
167
|
|
|
302
|
-
async function findUp(name, options) {
|
|
168
|
+
async function findUp(name, options = {}) {
|
|
303
169
|
const matches = await findUpMultiple(name, {...options, limit: 1});
|
|
304
170
|
return matches[0];
|
|
305
171
|
}
|
|
@@ -1189,7 +1055,7 @@ const invalidStep = (step, options) => {
|
|
|
1189
1055
|
return [];
|
|
1190
1056
|
};
|
|
1191
1057
|
|
|
1192
|
-
const fillNumbers = (start, end, step = 1, options) => {
|
|
1058
|
+
const fillNumbers = (start, end, step = 1, options = {}) => {
|
|
1193
1059
|
let a = Number(start);
|
|
1194
1060
|
let b = Number(end);
|
|
1195
1061
|
|
|
@@ -1241,7 +1107,7 @@ const fillNumbers = (start, end, step = 1, options) => {
|
|
|
1241
1107
|
return range;
|
|
1242
1108
|
};
|
|
1243
1109
|
|
|
1244
|
-
const fillLetters = (start, end, step = 1, options) => {
|
|
1110
|
+
const fillLetters = (start, end, step = 1, options = {}) => {
|
|
1245
1111
|
if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
|
|
1246
1112
|
return invalidRange(start, end, options);
|
|
1247
1113
|
}
|
|
@@ -7151,11 +7017,13 @@ const workerPath = pathToFileURL(resolve(distDir, "./worker.mjs")).href;
|
|
|
7151
7017
|
function createPool(ctx) {
|
|
7152
7018
|
var _a;
|
|
7153
7019
|
const threadsCount = ctx.config.watch ? Math.max(cpus().length / 2, 1) : Math.max(cpus().length - 1, 1);
|
|
7020
|
+
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7021
|
+
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
7154
7022
|
const options = {
|
|
7155
7023
|
filename: workerPath,
|
|
7156
7024
|
useAtomics: false,
|
|
7157
|
-
maxThreads
|
|
7158
|
-
minThreads
|
|
7025
|
+
maxThreads,
|
|
7026
|
+
minThreads
|
|
7159
7027
|
};
|
|
7160
7028
|
if (ctx.config.isolate) {
|
|
7161
7029
|
options.isolateWorkers = true;
|
|
@@ -7180,12 +7048,14 @@ function createPool(ctx) {
|
|
|
7180
7048
|
const config = ctx.getSerializableConfig();
|
|
7181
7049
|
async function runFiles(files, invalidates = []) {
|
|
7182
7050
|
const { workerPort, port } = createChannel(ctx);
|
|
7051
|
+
const workerId = ++id;
|
|
7183
7052
|
const data = {
|
|
7184
7053
|
port: workerPort,
|
|
7185
7054
|
config,
|
|
7186
7055
|
files,
|
|
7187
7056
|
invalidates,
|
|
7188
|
-
|
|
7057
|
+
workerId,
|
|
7058
|
+
poolId: !ctx.config.threads ? 1 : (workerId - 1) % maxThreads + 1
|
|
7189
7059
|
};
|
|
7190
7060
|
try {
|
|
7191
7061
|
await pool.run(data, { transferList: [workerPort], name });
|
|
@@ -7195,6 +7065,20 @@ function createPool(ctx) {
|
|
|
7195
7065
|
}
|
|
7196
7066
|
}
|
|
7197
7067
|
return async (files, invalidates) => {
|
|
7068
|
+
if (config.shard) {
|
|
7069
|
+
const { index, count } = config.shard;
|
|
7070
|
+
const shardSize = Math.ceil(files.length / count);
|
|
7071
|
+
const shardStart = shardSize * (index - 1);
|
|
7072
|
+
const shardEnd = shardSize * index;
|
|
7073
|
+
files = files.map((file) => {
|
|
7074
|
+
const fullPath = resolve(slash$2(config.root), slash$2(file));
|
|
7075
|
+
const specPath = fullPath.slice(config.root.length);
|
|
7076
|
+
return {
|
|
7077
|
+
file,
|
|
7078
|
+
hash: createHash("sha1").update(specPath).digest("hex")
|
|
7079
|
+
};
|
|
7080
|
+
}).sort((a, b) => a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0).slice(shardStart, shardEnd).map(({ file }) => file);
|
|
7081
|
+
}
|
|
7198
7082
|
if (!ctx.config.threads) {
|
|
7199
7083
|
await runFiles(files);
|
|
7200
7084
|
} else {
|
|
@@ -8963,7 +8847,7 @@ function resolveApiConfig(options) {
|
|
|
8963
8847
|
return api;
|
|
8964
8848
|
}
|
|
8965
8849
|
function resolveConfig(options, viteConfig) {
|
|
8966
|
-
var _a, _b;
|
|
8850
|
+
var _a, _b, _c;
|
|
8967
8851
|
if (options.dom) {
|
|
8968
8852
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
8969
8853
|
console.warn(picocolors.exports.yellow(`${picocolors.exports.inverse(picocolors.exports.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`));
|
|
@@ -8976,6 +8860,18 @@ function resolveConfig(options, viteConfig) {
|
|
|
8976
8860
|
if (viteConfig.base !== "/")
|
|
8977
8861
|
resolved.base = viteConfig.base;
|
|
8978
8862
|
resolved.coverage = resolveC8Options(options.coverage || {}, resolved.root);
|
|
8863
|
+
if (options.shard) {
|
|
8864
|
+
if (resolved.watch)
|
|
8865
|
+
throw new Error("You cannot use --shard option with enabled watch");
|
|
8866
|
+
const [indexString, countString] = options.shard.split("/");
|
|
8867
|
+
const index = Math.abs(parseInt(indexString, 10));
|
|
8868
|
+
const count = Math.abs(parseInt(countString, 10));
|
|
8869
|
+
if (isNaN(count) || count <= 0)
|
|
8870
|
+
throw new Error("--shard <count> must be a positive number");
|
|
8871
|
+
if (isNaN(index) || index <= 0 || index > count)
|
|
8872
|
+
throw new Error("--shard <index> must be a positive number less then <count>");
|
|
8873
|
+
resolved.shard = { index, count };
|
|
8874
|
+
}
|
|
8979
8875
|
resolved.deps = resolved.deps || {};
|
|
8980
8876
|
if (resolved.deps.inline !== true) {
|
|
8981
8877
|
const ssrOptions = viteConfig.ssr || {};
|
|
@@ -9012,6 +8908,9 @@ function resolveConfig(options, viteConfig) {
|
|
|
9012
8908
|
resolved.reporters.push("default");
|
|
9013
8909
|
if (resolved.changed)
|
|
9014
8910
|
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
8911
|
+
resolved.css ?? (resolved.css = {});
|
|
8912
|
+
if (typeof resolved.css === "object")
|
|
8913
|
+
(_c = resolved.css).include ?? (_c.include = [/\.module\./]);
|
|
9015
8914
|
return resolved;
|
|
9016
8915
|
}
|
|
9017
8916
|
|
|
@@ -9021,7 +8920,7 @@ function fileFromParsedStack(stack) {
|
|
|
9021
8920
|
return join(stack.file, "../", stack.sourcePos.source);
|
|
9022
8921
|
return stack.file;
|
|
9023
8922
|
}
|
|
9024
|
-
async function printError(error, ctx, options) {
|
|
8923
|
+
async function printError(error, ctx, options = {}) {
|
|
9025
8924
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
9026
8925
|
let e = error;
|
|
9027
8926
|
if (typeof error === "string") {
|
|
@@ -9143,7 +9042,7 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
|
|
|
9143
9042
|
ctx.log(picocolors.exports.red(picocolors.exports.bold("Serialized Error:")), picocolors.exports.gray(propertiesString));
|
|
9144
9043
|
}
|
|
9145
9044
|
}
|
|
9146
|
-
function generateCodeFrame(source, indent, start = 0, end, range = 2) {
|
|
9045
|
+
function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
9147
9046
|
var _a;
|
|
9148
9047
|
start = posToNumber(source, start);
|
|
9149
9048
|
end = end || start;
|
|
@@ -9236,7 +9135,7 @@ function npmRunPath(options = {}) {
|
|
|
9236
9135
|
return [...result, path_].join(path$a.delimiter);
|
|
9237
9136
|
}
|
|
9238
9137
|
|
|
9239
|
-
function npmRunPathEnv({env = process$1.env, ...options}) {
|
|
9138
|
+
function npmRunPathEnv({env = process$1.env, ...options} = {}) {
|
|
9240
9139
|
env = {...env};
|
|
9241
9140
|
|
|
9242
9141
|
const path = pathKey({env});
|
|
@@ -10896,6 +10795,34 @@ function getIndexStatus(code, from) {
|
|
|
10896
10795
|
};
|
|
10897
10796
|
}
|
|
10898
10797
|
|
|
10798
|
+
const cssLangs = "\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)";
|
|
10799
|
+
const cssLangRE = new RegExp(cssLangs);
|
|
10800
|
+
const isCSS = (id) => {
|
|
10801
|
+
return cssLangRE.test(id);
|
|
10802
|
+
};
|
|
10803
|
+
function CSSEnablerPlugin(ctx) {
|
|
10804
|
+
const shouldProcessCSS = (id) => {
|
|
10805
|
+
const { css } = ctx.config;
|
|
10806
|
+
if (typeof css === "boolean")
|
|
10807
|
+
return css;
|
|
10808
|
+
if (toArray$1(css.exclude).some((re) => re.test(id)))
|
|
10809
|
+
return false;
|
|
10810
|
+
if (toArray$1(css.include).some((re) => re.test(id)))
|
|
10811
|
+
return true;
|
|
10812
|
+
return false;
|
|
10813
|
+
};
|
|
10814
|
+
return {
|
|
10815
|
+
name: "vitest:css-enabler",
|
|
10816
|
+
enforce: "pre",
|
|
10817
|
+
transform(code, id) {
|
|
10818
|
+
if (!isCSS(id))
|
|
10819
|
+
return;
|
|
10820
|
+
if (!shouldProcessCSS(id))
|
|
10821
|
+
return "";
|
|
10822
|
+
}
|
|
10823
|
+
};
|
|
10824
|
+
}
|
|
10825
|
+
|
|
10899
10826
|
var __defProp = Object.defineProperty;
|
|
10900
10827
|
var __defProps = Object.defineProperties;
|
|
10901
10828
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -11005,10 +10932,15 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11005
10932
|
async configureServer(server) {
|
|
11006
10933
|
if (haveStarted)
|
|
11007
10934
|
await ctx.report("onServerRestart");
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
10935
|
+
try {
|
|
10936
|
+
await ctx.setServer(options, server);
|
|
10937
|
+
haveStarted = true;
|
|
10938
|
+
if (options.api && options.watch)
|
|
10939
|
+
(await import('./chunk-api-setup.ff687d0e.mjs')).setup(ctx);
|
|
10940
|
+
} catch (err) {
|
|
10941
|
+
ctx.printError(err, true);
|
|
10942
|
+
process.exit(1);
|
|
10943
|
+
}
|
|
11012
10944
|
if (!options.watch)
|
|
11013
10945
|
await server.watcher.close();
|
|
11014
10946
|
}
|
|
@@ -11016,6 +10948,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
11016
10948
|
EnvReplacerPlugin(),
|
|
11017
10949
|
MocksPlugin(),
|
|
11018
10950
|
GlobalSetupPlugin(ctx),
|
|
10951
|
+
CSSEnablerPlugin(ctx),
|
|
11019
10952
|
options.ui ? await UIPlugin() : null
|
|
11020
10953
|
].filter(notNullish);
|
|
11021
10954
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { builtinModules, createRequire } from 'module';
|
|
2
2
|
import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
|
-
import {
|
|
4
|
+
import { o as isAbsolute$2, m as resolve, j as join$2, I as extname$2, d as dirname$2 } from './chunk-utils-global.79a8b1cc.mjs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
|
|
7
7
|
import assert from 'assert';
|
|
@@ -2776,7 +2776,7 @@ const compare$b = compare_1$1;
|
|
|
2776
2776
|
// - If no C has a prerelease and the LT.semver tuple, return false
|
|
2777
2777
|
// - Else return true
|
|
2778
2778
|
|
|
2779
|
-
const subset$1 = (sub, dom, options) => {
|
|
2779
|
+
const subset$1 = (sub, dom, options = {}) => {
|
|
2780
2780
|
if (sub === dom)
|
|
2781
2781
|
return true
|
|
2782
2782
|
|
|
@@ -7290,7 +7290,7 @@ const compare = compare_1;
|
|
|
7290
7290
|
// - If no C has a prerelease and the LT.semver tuple, return false
|
|
7291
7291
|
// - Else return true
|
|
7292
7292
|
|
|
7293
|
-
const subset = (sub, dom, options) => {
|
|
7293
|
+
const subset = (sub, dom, options = {}) => {
|
|
7294
7294
|
if (sub === dom)
|
|
7295
7295
|
return true
|
|
7296
7296
|
|
|
@@ -7948,7 +7948,7 @@ const defaultFindOptions = {
|
|
|
7948
7948
|
return null;
|
|
7949
7949
|
}
|
|
7950
7950
|
};
|
|
7951
|
-
async function findNearestFile(filename, _options) {
|
|
7951
|
+
async function findNearestFile(filename, _options = {}) {
|
|
7952
7952
|
const options = { ...defaultFindOptions, ..._options };
|
|
7953
7953
|
const basePath = resolve(options.startingFrom);
|
|
7954
7954
|
const leadingSlash = basePath[0] === "/";
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.79a8b1cc.mjs';
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.db158bfb.mjs';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
@@ -8,22 +8,23 @@ 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 './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
17
|
-
import './chunk-vite-node-utils.
|
|
18
|
-
import 'module';
|
|
19
|
+
import './chunk-vite-node-utils.c0a0e1b3.mjs';
|
|
19
20
|
import 'vm';
|
|
20
21
|
import 'assert';
|
|
21
22
|
import 'debug';
|
|
22
|
-
import './chunk-defaults.45dc5e3d.mjs';
|
|
23
23
|
import 'worker_threads';
|
|
24
|
+
import 'crypto';
|
|
24
25
|
import 'tinypool';
|
|
25
26
|
import 'perf_hooks';
|
|
26
|
-
import './chunk-utils-source-map.
|
|
27
|
+
import './chunk-utils-source-map.2556cba8.mjs';
|
|
27
28
|
import './vendor-index.e5dc6622.mjs';
|
|
28
29
|
import 'child_process';
|
|
29
30
|
import 'buffer';
|
|
@@ -641,10 +642,10 @@ class CAC extends EventEmitter {
|
|
|
641
642
|
}
|
|
642
643
|
}
|
|
643
644
|
|
|
644
|
-
const cac = (name) => new CAC(name);
|
|
645
|
+
const cac = (name = "") => new CAC(name);
|
|
645
646
|
|
|
646
647
|
const cli = cac("vitest");
|
|
647
|
-
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("--changed [since]", "Run tests that are affected by the changed files (default: false)").help();
|
|
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)").help();
|
|
648
649
|
cli.command("run [...filters]").action(run);
|
|
649
650
|
cli.command("related [...filters]").action(runRelated);
|
|
650
651
|
cli.command("watch [...filters]").action(start);
|
package/dist/config.cjs
CHANGED
|
@@ -63,8 +63,12 @@ const config = {
|
|
|
63
63
|
ui: false,
|
|
64
64
|
uiBase: "/__vitest__/",
|
|
65
65
|
open: true,
|
|
66
|
+
css: {
|
|
67
|
+
include: [/\.module\./]
|
|
68
|
+
},
|
|
66
69
|
coverage: coverageConfigDefaults,
|
|
67
|
-
fakeTimers: fakeTimersDefaults
|
|
70
|
+
fakeTimers: fakeTimersDefaults,
|
|
71
|
+
maxConcurrency: 5
|
|
68
72
|
};
|
|
69
73
|
const configDefaults = Object.freeze(config);
|
|
70
74
|
|
package/dist/config.d.ts
CHANGED
|
@@ -91,8 +91,12 @@ declare const config: {
|
|
|
91
91
|
ui: boolean;
|
|
92
92
|
uiBase: string;
|
|
93
93
|
open: boolean;
|
|
94
|
+
css: {
|
|
95
|
+
include: RegExp[];
|
|
96
|
+
};
|
|
94
97
|
coverage: ResolvedC8Options;
|
|
95
98
|
fakeTimers: FakeTimerInstallOpts;
|
|
99
|
+
maxConcurrency: number;
|
|
96
100
|
};
|
|
97
101
|
declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
|
|
98
102
|
|
package/dist/config.mjs
CHANGED
|
@@ -59,8 +59,12 @@ const config = {
|
|
|
59
59
|
ui: false,
|
|
60
60
|
uiBase: "/__vitest__/",
|
|
61
61
|
open: true,
|
|
62
|
+
css: {
|
|
63
|
+
include: [/\.module\./]
|
|
64
|
+
},
|
|
62
65
|
coverage: coverageConfigDefaults,
|
|
63
|
-
fakeTimers: fakeTimersDefaults
|
|
66
|
+
fakeTimers: fakeTimersDefaults,
|
|
67
|
+
maxConcurrency: 5
|
|
64
68
|
};
|
|
65
69
|
const configDefaults = Object.freeze(config);
|
|
66
70
|
|
package/dist/entry.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export { r as run } from './vendor-entry.
|
|
1
|
+
export { r as run } from './vendor-entry.7ec02ea2.mjs';
|
|
2
2
|
import 'fs';
|
|
3
|
-
import './chunk-utils-global.
|
|
3
|
+
import './chunk-utils-global.79a8b1cc.mjs';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
7
|
-
import './chunk-runtime-chain.
|
|
7
|
+
import './chunk-runtime-chain.ce7f4b92.mjs';
|
|
8
8
|
import 'chai';
|
|
9
9
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
10
|
-
import './chunk-runtime-rpc.
|
|
11
|
-
import './chunk-utils-source-map.
|
|
10
|
+
import './chunk-runtime-rpc.5e78af38.mjs';
|
|
11
|
+
import './chunk-utils-source-map.2556cba8.mjs';
|
|
12
12
|
import './chunk-integrations-spy.674b628e.mjs';
|
|
13
13
|
import 'tinyspy';
|
|
14
14
|
import 'util';
|
|
15
|
-
import './chunk-defaults.
|
|
15
|
+
import './chunk-defaults.dc6dc23d.mjs';
|
|
16
16
|
import 'module';
|
|
17
17
|
import 'url';
|
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;
|
|
@@ -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[];
|
|
@@ -1617,7 +1645,7 @@ declare function runOnce<T>(fn: (() => T), key?: string): T;
|
|
|
1617
1645
|
declare function isFirstRun(): boolean;
|
|
1618
1646
|
|
|
1619
1647
|
declare function createExpect(test?: Test): Vi.ExpectStatic;
|
|
1620
|
-
declare const
|
|
1648
|
+
declare const globalExpect: Vi.ExpectStatic;
|
|
1621
1649
|
|
|
1622
1650
|
declare class VitestUtils {
|
|
1623
1651
|
private _timers;
|
|
@@ -1737,4 +1765,4 @@ interface WebSocketHandlers {
|
|
|
1737
1765
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog'> {
|
|
1738
1766
|
}
|
|
1739
1767
|
|
|
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 };
|
|
1768
|
+
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.ce7f4b92.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';
|