vitest 0.26.3 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +15 -66
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +15 -15
- package/dist/{chunk-api-setup.47a09f0f.js → chunk-api-setup.2be3cc38.js} +60 -31
- package/dist/{chunk-install-pkg.6dd2bae6.js → chunk-install-pkg.7b006b3e.js} +8 -8
- package/dist/{chunk-integrations-coverage.befed097.js → chunk-integrations-coverage.44413252.js} +19 -1
- package/dist/chunk-integrations-globals.02f1259c.js +27 -0
- package/dist/{chunk-typecheck-constants.06e1fe5b.js → chunk-mock-date.149ed990.js} +19 -32
- package/dist/{chunk-node-git.a90c0582.js → chunk-node-git.125c9008.js} +3 -4
- package/dist/{chunk-runtime-chain.f51aa930.js → chunk-runtime-chain.4e2aa823.js} +1193 -1029
- package/dist/{chunk-runtime-error.f5c8aaf2.js → chunk-runtime-error.97854396.js} +2 -2
- package/dist/{chunk-runtime-mocker.887bf8c8.js → chunk-runtime-mocker.4755840f.js} +10 -8
- package/dist/{chunk-runtime-rpc.54d72169.js → chunk-runtime-rpc.25cc9413.js} +2 -2
- package/dist/{chunk-runtime-setup.a06d5c72.js → chunk-runtime-setup.56d71d30.js} +51 -52
- package/dist/{chunk-snapshot-manager.70695b70.js → chunk-snapshot-manager.1a2dbf96.js} +468 -302
- package/dist/{chunk-utils-env.3fdc1793.js → chunk-utils-env.f4a39d2c.js} +8 -70
- package/dist/{chunk-utils-import.e7f64637.js → chunk-utils-import.16d9fb0d.js} +22 -8
- package/dist/chunk-utils-source-map.4e9b891d.js +408 -0
- package/dist/{chunk-utils-timers.715da787.js → chunk-utils-timers.52534f96.js} +2977 -3458
- package/dist/cli-wrapper.js +15 -15
- package/dist/cli.js +15 -627
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -1
- package/dist/entry.js +14 -14
- package/dist/environments.d.ts +1 -1
- package/dist/{index-761e769b.d.ts → index-1cfc7f58.d.ts} +4 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/loader.js +9 -10
- package/dist/node.d.ts +2 -2
- package/dist/node.js +14 -12
- package/dist/spy.js +2 -102
- package/dist/suite.js +10 -10
- package/dist/{types-bae746aa.d.ts → types-5617096e.d.ts} +97 -77
- package/dist/{vendor-index.b2fdde54.js → vendor-index.451e37bc.js} +1 -1
- package/dist/vendor-index.723a074f.js +102 -0
- package/dist/vendor-index.b0346fe4.js +395 -0
- package/dist/{vendor-index.7a2cebfe.js → vendor-index.e6c27006.js} +12 -12
- package/dist/worker.js +24 -19
- package/package.json +13 -8
- package/dist/chunk-integrations-globals.ee28730b.js +0 -27
- package/dist/chunk-utils-source-map.5278ee22.js +0 -86
- package/dist/vendor-index.2e96c50b.js +0 -215
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
|
-
import
|
|
2
|
+
import c from 'picocolors';
|
|
3
3
|
import { isPackageExists } from 'local-pkg';
|
|
4
|
-
|
|
5
|
-
const TYPECHECK_SUITE = Symbol("vitest:typecheck-suite");
|
|
4
|
+
import { i as isNode, a as isBrowser, r as relative$1, E as EXIT_CODE_RESTART } from './chunk-utils-env.f4a39d2c.js';
|
|
6
5
|
|
|
7
6
|
const RealDate = Date;
|
|
8
7
|
let now = null;
|
|
@@ -61,8 +60,8 @@ function collectOwnProperties(obj, collector) {
|
|
|
61
60
|
Object.getOwnPropertyNames(obj).forEach(collect);
|
|
62
61
|
Object.getOwnPropertySymbols(obj).forEach(collect);
|
|
63
62
|
}
|
|
64
|
-
function getAllMockableProperties(obj) {
|
|
65
|
-
const allProps = /* @__PURE__ */ new
|
|
63
|
+
function getAllMockableProperties(obj, isModule) {
|
|
64
|
+
const allProps = /* @__PURE__ */ new Map();
|
|
66
65
|
let curr = obj;
|
|
67
66
|
do {
|
|
68
67
|
if (isFinalObj(curr))
|
|
@@ -70,10 +69,15 @@ function getAllMockableProperties(obj) {
|
|
|
70
69
|
collectOwnProperties(curr, (key) => {
|
|
71
70
|
const descriptor = Object.getOwnPropertyDescriptor(curr, key);
|
|
72
71
|
if (descriptor)
|
|
73
|
-
allProps.
|
|
72
|
+
allProps.set(key, { key, descriptor });
|
|
74
73
|
});
|
|
75
74
|
} while (curr = Object.getPrototypeOf(curr));
|
|
76
|
-
|
|
75
|
+
if (isModule && !allProps.has("default") && "default" in obj) {
|
|
76
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, "default");
|
|
77
|
+
if (descriptor)
|
|
78
|
+
allProps.set("default", { key: "default", descriptor });
|
|
79
|
+
}
|
|
80
|
+
return Array.from(allProps.values());
|
|
77
81
|
}
|
|
78
82
|
function notNullish(v) {
|
|
79
83
|
return v != null;
|
|
@@ -152,12 +156,6 @@ function deepMerge(target, ...sources) {
|
|
|
152
156
|
function isMergeableObject(item) {
|
|
153
157
|
return isPlainObject(item) && !Array.isArray(item);
|
|
154
158
|
}
|
|
155
|
-
function assertTypes(value, name, types) {
|
|
156
|
-
const receivedType = typeof value;
|
|
157
|
-
const pass = types.includes(receivedType);
|
|
158
|
-
if (!pass)
|
|
159
|
-
throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
|
|
160
|
-
}
|
|
161
159
|
function stdout() {
|
|
162
160
|
return console._stdout || process.stdout;
|
|
163
161
|
}
|
|
@@ -178,21 +176,11 @@ function shuffle(array, seed = RealDate.now()) {
|
|
|
178
176
|
}
|
|
179
177
|
|
|
180
178
|
function isAtomTest(s) {
|
|
181
|
-
return s.type === "test" || s.type === "benchmark"
|
|
179
|
+
return s.type === "test" || s.type === "benchmark";
|
|
182
180
|
}
|
|
183
181
|
function getTests(suite) {
|
|
184
182
|
return toArray(suite).flatMap((s) => isAtomTest(s) ? [s] : s.tasks.flatMap((c) => isAtomTest(c) ? [c] : getTests(c)));
|
|
185
183
|
}
|
|
186
|
-
function isTypecheckTest(suite) {
|
|
187
|
-
return TYPECHECK_SUITE in suite;
|
|
188
|
-
}
|
|
189
|
-
function getTypecheckTests(suite) {
|
|
190
|
-
return toArray(suite).flatMap((s) => {
|
|
191
|
-
if (s.type !== "suite")
|
|
192
|
-
return [];
|
|
193
|
-
return TYPECHECK_SUITE in s ? [s, ...getTypecheckTests(s.tasks)] : getTypecheckTests(s.tasks);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
184
|
function getSuites(suite) {
|
|
197
185
|
return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
|
|
198
186
|
}
|
|
@@ -208,8 +196,7 @@ function hasFailed(suite) {
|
|
|
208
196
|
function hasFailedSnapshot(suite) {
|
|
209
197
|
return getTests(suite).some((s) => {
|
|
210
198
|
var _a, _b;
|
|
211
|
-
|
|
212
|
-
return message == null ? void 0 : message.match(/Snapshot .* mismatched/);
|
|
199
|
+
return (_b = (_a = s.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.some((e) => e.message.match(/Snapshot .* mismatched/));
|
|
213
200
|
});
|
|
214
201
|
}
|
|
215
202
|
function getNames(task) {
|
|
@@ -265,7 +252,7 @@ function resetModules(modules, resetMocks = false) {
|
|
|
265
252
|
});
|
|
266
253
|
}
|
|
267
254
|
function getFullName(task) {
|
|
268
|
-
return getNames(task).join(
|
|
255
|
+
return getNames(task).join(c.dim(" > "));
|
|
269
256
|
}
|
|
270
257
|
function removeUndefinedValues(obj) {
|
|
271
258
|
for (const key in Object.keys(obj)) {
|
|
@@ -278,7 +265,7 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
278
265
|
if (isPackageExists(dependency, { paths: [root] }))
|
|
279
266
|
return true;
|
|
280
267
|
const promptInstall = !process.env.CI && process.stdout.isTTY;
|
|
281
|
-
process.stderr.write(
|
|
268
|
+
process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
|
282
269
|
|
|
283
270
|
`));
|
|
284
271
|
if (!promptInstall)
|
|
@@ -287,11 +274,11 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
287
274
|
const { install } = await prompts.prompt({
|
|
288
275
|
type: "confirm",
|
|
289
276
|
name: "install",
|
|
290
|
-
message:
|
|
277
|
+
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
291
278
|
});
|
|
292
279
|
if (install) {
|
|
293
|
-
await (await import('./chunk-install-pkg.
|
|
294
|
-
process.stderr.write(
|
|
280
|
+
await (await import('./chunk-install-pkg.7b006b3e.js')).installPackage(dependency, { dev: true });
|
|
281
|
+
process.stderr.write(c.yellow(`
|
|
295
282
|
Package ${dependency} installed, re-run the command to start.
|
|
296
283
|
`));
|
|
297
284
|
process.exit(EXIT_CODE_RESTART);
|
|
@@ -356,4 +343,4 @@ function objectAttr(source, path, defaultValue = void 0) {
|
|
|
356
343
|
return result;
|
|
357
344
|
}
|
|
358
345
|
|
|
359
|
-
export { AggregateErrorPonyfill as A,
|
|
346
|
+
export { AggregateErrorPonyfill as A, hasFailedSnapshot as B, getSuites as C, deepMerge as D, removeUndefinedValues as E, isWindows as F, stdout as G, getAllMockableProperties as H, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, getCurrentEnvironment as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, relativePath as k, shuffle as l, mockDate as m, noop as n, objectAttr as o, partitionSuiteChildren as p, hasTests as q, resetDate as r, slash as s, toArray as t, hasFailed as u, createDefer as v, deepClone as w, getType as x, ensurePackageInstalled as y, getTests as z };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { b as resolve } from './chunk-utils-env.
|
|
2
|
-
import { e as execa } from './vendor-index.
|
|
3
|
-
import 'tty';
|
|
1
|
+
import { b as resolve } from './chunk-utils-env.f4a39d2c.js';
|
|
2
|
+
import { e as execa } from './vendor-index.451e37bc.js';
|
|
4
3
|
import 'node:url';
|
|
5
4
|
import 'path';
|
|
6
5
|
import 'node:buffer';
|
|
7
6
|
import 'node:path';
|
|
8
7
|
import 'node:child_process';
|
|
9
8
|
import 'node:process';
|
|
10
|
-
import './vendor-index.
|
|
9
|
+
import './vendor-index.e6c27006.js';
|
|
11
10
|
import 'child_process';
|
|
12
11
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
13
12
|
import 'fs';
|