vitest 0.0.122 → 0.0.126
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/README.md +1 -3
- package/dist/cli.js +12 -6
- package/dist/{constants-22bbd600.js → constants-8b3a9b31.js} +1 -1
- package/dist/{diff-a295cb37.js → diff-3adb959a.js} +34 -20
- package/dist/entry.js +18 -27
- package/dist/externalize-2f63779d.js +9258 -0
- package/dist/{global-71c4f178.js → global-eb23b22e.js} +6 -6
- package/dist/{index-3cd686b2.js → index-4b6e78b4.js} +3 -2
- package/dist/{index-090545ef.js → index-9fdde2e8.js} +25 -27
- package/dist/{index-123a18df.js → index-e04b9e4c.js} +66 -28
- package/dist/index.d.ts +49 -14
- package/dist/index.js +4 -4
- package/dist/{jest-mock-038a01b3.js → jest-mock-30625866.js} +4 -1
- package/dist/node.d.ts +47 -9
- package/dist/node.js +5 -5
- package/dist/{setup-c9c7cb5b.js → setup-b0d2ca33.js} +50 -4
- package/dist/{vi-c99184a5.js → vi-5ff3926d.js} +42 -41
- package/dist/worker.js +27 -9244
- package/package.json +13 -8
- package/dist/utils.js +0 -5
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-8b3a9b31.js';
|
|
2
|
+
import { i as index } from './index-4b6e78b4.js';
|
|
3
3
|
import 'url';
|
|
4
|
-
import './index-
|
|
4
|
+
import './index-9fdde2e8.js';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
|
-
import './vi-
|
|
9
|
-
import './
|
|
10
|
-
import './jest-mock-038a01b3.js';
|
|
8
|
+
import './vi-5ff3926d.js';
|
|
9
|
+
import './jest-mock-30625866.js';
|
|
11
10
|
import 'chai';
|
|
12
11
|
import 'tinyspy';
|
|
12
|
+
import './_commonjsHelpers-c9e3b764.js';
|
|
13
13
|
|
|
14
14
|
function registerApiGlobally() {
|
|
15
15
|
globalApis.forEach((api) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-5ff3926d.js';
|
|
2
2
|
import chai, { assert, should } from 'chai';
|
|
3
|
-
import { s as spies, a as spyOn, f as fn } from './jest-mock-
|
|
3
|
+
import { s as spies, i as isMockFunction, a as spyOn, f as fn } from './jest-mock-30625866.js';
|
|
4
4
|
|
|
5
5
|
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
6
6
|
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
@@ -29,6 +29,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
29
29
|
chai: chai,
|
|
30
30
|
expect: expect,
|
|
31
31
|
spies: spies,
|
|
32
|
+
isMockFunction: isMockFunction,
|
|
32
33
|
spyOn: spyOn,
|
|
33
34
|
fn: fn,
|
|
34
35
|
vitest: vitest,
|
|
@@ -249,13 +249,6 @@ const index = {
|
|
|
249
249
|
..._path
|
|
250
250
|
};
|
|
251
251
|
|
|
252
|
-
const isWindows = process.platform === "win32";
|
|
253
|
-
function toArray(array) {
|
|
254
|
-
array = array || [];
|
|
255
|
-
if (Array.isArray(array))
|
|
256
|
-
return array;
|
|
257
|
-
return [array];
|
|
258
|
-
}
|
|
259
252
|
function notNullish(v) {
|
|
260
253
|
return v != null;
|
|
261
254
|
}
|
|
@@ -267,32 +260,20 @@ function mergeSlashes(str) {
|
|
|
267
260
|
}
|
|
268
261
|
const noop = () => {
|
|
269
262
|
};
|
|
270
|
-
function
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
tasksGroup.push(c2);
|
|
276
|
-
} else {
|
|
277
|
-
tasksGroups.push(tasksGroup);
|
|
278
|
-
tasksGroup = [c2];
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (tasksGroup.length > 0)
|
|
282
|
-
tasksGroups.push(tasksGroup);
|
|
283
|
-
return tasksGroups;
|
|
263
|
+
function toArray(array) {
|
|
264
|
+
array = array || [];
|
|
265
|
+
if (Array.isArray(array))
|
|
266
|
+
return array;
|
|
267
|
+
return [array];
|
|
284
268
|
}
|
|
285
269
|
function getTests(suite) {
|
|
286
|
-
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((
|
|
287
|
-
}
|
|
288
|
-
function getTasks(tasks) {
|
|
289
|
-
return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
|
|
270
|
+
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
|
|
290
271
|
}
|
|
291
272
|
function getSuites(suite) {
|
|
292
273
|
return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
|
|
293
274
|
}
|
|
294
275
|
function hasTests(suite) {
|
|
295
|
-
return toArray(suite).some((s) => s.tasks.some((
|
|
276
|
+
return toArray(suite).some((s) => s.tasks.some((c) => c.type === "test" || hasTests(c)));
|
|
296
277
|
}
|
|
297
278
|
function hasFailed(suite) {
|
|
298
279
|
return toArray(suite).some((s) => {
|
|
@@ -310,6 +291,23 @@ function getNames(task) {
|
|
|
310
291
|
}
|
|
311
292
|
return names;
|
|
312
293
|
}
|
|
294
|
+
|
|
295
|
+
const isWindows = process.platform === "win32";
|
|
296
|
+
function partitionSuiteChildren(suite) {
|
|
297
|
+
let tasksGroup = [];
|
|
298
|
+
const tasksGroups = [];
|
|
299
|
+
for (const c2 of suite.tasks) {
|
|
300
|
+
if (tasksGroup.length === 0 || c2.concurrent === tasksGroup[0].concurrent) {
|
|
301
|
+
tasksGroup.push(c2);
|
|
302
|
+
} else {
|
|
303
|
+
tasksGroups.push(tasksGroup);
|
|
304
|
+
tasksGroup = [c2];
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (tasksGroup.length > 0)
|
|
308
|
+
tasksGroups.push(tasksGroup);
|
|
309
|
+
return tasksGroups;
|
|
310
|
+
}
|
|
313
311
|
function getFullName(task) {
|
|
314
312
|
return getNames(task).join(c.dim(" > "));
|
|
315
313
|
}
|
|
@@ -365,4 +363,4 @@ function toFilePath(id, root) {
|
|
|
365
363
|
return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
|
|
366
364
|
}
|
|
367
365
|
|
|
368
|
-
export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x
|
|
366
|
+
export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs$8, { promises, existsSync } from 'fs';
|
|
2
|
+
import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1, e as ensurePackageInstalled } from './index-9fdde2e8.js';
|
|
2
3
|
import { createServer, mergeConfig } from 'vite';
|
|
3
4
|
import path$a from 'path';
|
|
4
5
|
import process$1 from 'process';
|
|
5
|
-
import fs$8, { promises, existsSync } from 'fs';
|
|
6
6
|
import require$$0 from 'os';
|
|
7
7
|
import require$$0$1 from 'util';
|
|
8
8
|
import require$$0$2 from 'stream';
|
|
9
9
|
import require$$2 from 'events';
|
|
10
|
-
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-
|
|
10
|
+
import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-8b3a9b31.js';
|
|
11
11
|
import MagicString from './magic-string.es-94000aea.js';
|
|
12
12
|
import { performance } from 'perf_hooks';
|
|
13
|
-
import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-
|
|
13
|
+
import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-3adb959a.js';
|
|
14
14
|
import { o as onetime, s as signalExit } from './index-648e7ab2.js';
|
|
15
15
|
import { createRequire } from 'module';
|
|
16
16
|
import { pathToFileURL } from 'url';
|
|
@@ -6840,7 +6840,7 @@ const MocksPlugin = () => {
|
|
|
6840
6840
|
if (m) {
|
|
6841
6841
|
return {
|
|
6842
6842
|
code: m.toString(),
|
|
6843
|
-
map: m.generateMap()
|
|
6843
|
+
map: m.generateMap({ hires: true })
|
|
6844
6844
|
};
|
|
6845
6845
|
}
|
|
6846
6846
|
}
|
|
@@ -7058,9 +7058,9 @@ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")
|
|
|
7058
7058
|
await this.printTaskErrors(failedTests, errorDivider);
|
|
7059
7059
|
}
|
|
7060
7060
|
const executionTime = this.end - this.start;
|
|
7061
|
-
const threadTime =
|
|
7061
|
+
const threadTime = files.reduce((acc, test) => {
|
|
7062
7062
|
var _a;
|
|
7063
|
-
return acc + (((_a = test.result) == null ? void 0 : _a.
|
|
7063
|
+
return acc + (((_a = test.result) == null ? void 0 : _a.duration) || 0) + (test.collectDuration || 0);
|
|
7064
7064
|
}, 0);
|
|
7065
7065
|
const padTitle = (str) => c.dim(`${str.padStart(10)} `);
|
|
7066
7066
|
const time = (time2) => {
|
|
@@ -7597,7 +7597,6 @@ createLogUpdate(process$1.stdout);
|
|
|
7597
7597
|
createLogUpdate(process$1.stderr);
|
|
7598
7598
|
|
|
7599
7599
|
const DURATION_LONG = 300;
|
|
7600
|
-
const MAX_HEIGHT = 20;
|
|
7601
7600
|
const outputMap = new WeakMap();
|
|
7602
7601
|
function formatFilepath(path) {
|
|
7603
7602
|
const lastSlash = Math.max(path.lastIndexOf("/") + 1, 0);
|
|
@@ -7618,10 +7617,9 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7618
7617
|
suffix += c.dim(` (${getTests(task).length})`);
|
|
7619
7618
|
if (task.mode === "skip" || task.mode === "todo")
|
|
7620
7619
|
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
7621
|
-
if ((_a = task.result) == null ? void 0 : _a.
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
suffix += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
|
|
7620
|
+
if (((_a = task.result) == null ? void 0 : _a.duration) != null) {
|
|
7621
|
+
if (task.result.duration > DURATION_LONG)
|
|
7622
|
+
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
7625
7623
|
}
|
|
7626
7624
|
let name = task.name;
|
|
7627
7625
|
if (level === 0)
|
|
@@ -7644,7 +7642,7 @@ function renderTree(tasks, options, level = 0) {
|
|
|
7644
7642
|
output = output.concat(renderTree(task.tasks, options, level + 1));
|
|
7645
7643
|
}
|
|
7646
7644
|
}
|
|
7647
|
-
return output.
|
|
7645
|
+
return output.join("\n");
|
|
7648
7646
|
}
|
|
7649
7647
|
const createListRenderer = (_tasks, options) => {
|
|
7650
7648
|
let tasks = _tasks;
|
|
@@ -7946,7 +7944,7 @@ var __spreadValues = (a, b) => {
|
|
|
7946
7944
|
};
|
|
7947
7945
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7948
7946
|
function resolveConfig(options, viteConfig) {
|
|
7949
|
-
var _a, _b;
|
|
7947
|
+
var _a, _b, _c, _d;
|
|
7950
7948
|
if (options.dom)
|
|
7951
7949
|
options.environment = "happy-dom";
|
|
7952
7950
|
const resolved = __spreadProps(__spreadValues({}, deepMerge(options, viteConfig.test)), {
|
|
@@ -7955,9 +7953,10 @@ function resolveConfig(options, viteConfig) {
|
|
|
7955
7953
|
resolved.coverage = resolveC8Options(resolved.coverage, resolved.root);
|
|
7956
7954
|
resolved.depsInline = [...((_a = resolved.deps) == null ? void 0 : _a.inline) || []];
|
|
7957
7955
|
resolved.depsExternal = [...((_b = resolved.deps) == null ? void 0 : _b.external) || []];
|
|
7956
|
+
resolved.fallbackCJS = ((_c = resolved.deps) == null ? void 0 : _c.fallbackCJS) ?? true;
|
|
7957
|
+
resolved.interpretDefault = ((_d = resolved.deps) == null ? void 0 : _d.interpretDefault) ?? true;
|
|
7958
7958
|
resolved.environment = resolved.environment || "node";
|
|
7959
7959
|
resolved.threads = resolved.threads ?? true;
|
|
7960
|
-
resolved.interpretDefault = resolved.interpretDefault ?? true;
|
|
7961
7960
|
resolved.clearMocks = resolved.clearMocks ?? false;
|
|
7962
7961
|
resolved.restoreMocks = resolved.restoreMocks ?? false;
|
|
7963
7962
|
resolved.mockReset = resolved.mockReset ?? false;
|
|
@@ -7980,8 +7979,8 @@ function resolveConfig(options, viteConfig) {
|
|
|
7980
7979
|
resolved.setupFiles = Array.from(resolved.setupFiles || []).map((i) => resolve(resolved.root, i));
|
|
7981
7980
|
if (resolved.api === true)
|
|
7982
7981
|
resolved.api = defaultPort;
|
|
7983
|
-
if (options.
|
|
7984
|
-
resolved.
|
|
7982
|
+
if (options.related)
|
|
7983
|
+
resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
|
|
7985
7984
|
return resolved;
|
|
7986
7985
|
}
|
|
7987
7986
|
|
|
@@ -8188,7 +8187,7 @@ class Vitest {
|
|
|
8188
8187
|
}
|
|
8189
8188
|
async start(filters) {
|
|
8190
8189
|
this.report("onInit", this);
|
|
8191
|
-
const files = await this.globTestFiles(filters);
|
|
8190
|
+
const files = await this.filterTestsBySource(await this.globTestFiles(filters));
|
|
8192
8191
|
if (!files.length) {
|
|
8193
8192
|
if (this.config.passWithNoTests)
|
|
8194
8193
|
this.log("No test files found\n");
|
|
@@ -8202,6 +8201,42 @@ class Vitest {
|
|
|
8202
8201
|
if (this.config.coverage.enabled)
|
|
8203
8202
|
await reportCoverage(this);
|
|
8204
8203
|
}
|
|
8204
|
+
async getTestDependencies(filepath) {
|
|
8205
|
+
const deps = new Set();
|
|
8206
|
+
const addImports = async (filepath2) => {
|
|
8207
|
+
const transformed = await this.server.transformRequest(filepath2, { ssr: true });
|
|
8208
|
+
if (!transformed)
|
|
8209
|
+
return;
|
|
8210
|
+
const dependencies = [...transformed.deps || [], ...transformed.dynamicDeps || []];
|
|
8211
|
+
for (const dep of dependencies) {
|
|
8212
|
+
const path = await this.server.pluginContainer.resolveId(dep, filepath2, { ssr: true });
|
|
8213
|
+
const fsPath = path && !path.external && path.id.split("?")[0];
|
|
8214
|
+
if (fsPath && !fsPath.includes("node_modules") && !deps.has(fsPath) && existsSync(fsPath)) {
|
|
8215
|
+
deps.add(fsPath);
|
|
8216
|
+
await addImports(fsPath);
|
|
8217
|
+
}
|
|
8218
|
+
}
|
|
8219
|
+
};
|
|
8220
|
+
await addImports(filepath);
|
|
8221
|
+
return deps;
|
|
8222
|
+
}
|
|
8223
|
+
async filterTestsBySource(tests) {
|
|
8224
|
+
const related = this.config.related;
|
|
8225
|
+
if (!related)
|
|
8226
|
+
return tests;
|
|
8227
|
+
if (!related.length)
|
|
8228
|
+
return [];
|
|
8229
|
+
const testDeps = await Promise.all(tests.map(async (filepath) => {
|
|
8230
|
+
const deps = await this.getTestDependencies(filepath);
|
|
8231
|
+
return [filepath, deps];
|
|
8232
|
+
}));
|
|
8233
|
+
const runningTests = [];
|
|
8234
|
+
for (const [filepath, deps] of testDeps) {
|
|
8235
|
+
if (deps.size && related.some((path) => deps.has(path)))
|
|
8236
|
+
runningTests.push(filepath);
|
|
8237
|
+
}
|
|
8238
|
+
return runningTests;
|
|
8239
|
+
}
|
|
8205
8240
|
async runFiles(files) {
|
|
8206
8241
|
await this.runningPromise;
|
|
8207
8242
|
this.runningPromise = (async () => {
|
|
@@ -8345,6 +8380,12 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8345
8380
|
const root = resolve(options.root || process.cwd());
|
|
8346
8381
|
const configPath = options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
8347
8382
|
let haveStarted = false;
|
|
8383
|
+
async function UIPlugin() {
|
|
8384
|
+
if (!options.open)
|
|
8385
|
+
return;
|
|
8386
|
+
await ensurePackageInstalled("@vitest/ui");
|
|
8387
|
+
return (await import('@vitest/ui')).default();
|
|
8388
|
+
}
|
|
8348
8389
|
const config = {
|
|
8349
8390
|
root,
|
|
8350
8391
|
logLevel: "error",
|
|
@@ -8359,29 +8400,26 @@ async function createVitest(options, viteOverrides = {}) {
|
|
|
8359
8400
|
await ctx.setServer(options, server2);
|
|
8360
8401
|
haveStarted = true;
|
|
8361
8402
|
if (options.api)
|
|
8362
|
-
(await import('./setup-
|
|
8403
|
+
(await import('./setup-b0d2ca33.js')).setup(ctx);
|
|
8363
8404
|
}
|
|
8364
8405
|
},
|
|
8365
|
-
MocksPlugin()
|
|
8406
|
+
MocksPlugin(),
|
|
8407
|
+
await UIPlugin()
|
|
8366
8408
|
],
|
|
8367
8409
|
server: {
|
|
8368
|
-
open: options.open,
|
|
8369
|
-
strictPort: true
|
|
8410
|
+
open: options.open ? "/__vitest__/" : void 0,
|
|
8411
|
+
strictPort: true,
|
|
8412
|
+
preTransformRequests: false
|
|
8370
8413
|
},
|
|
8371
8414
|
build: {
|
|
8372
8415
|
sourcemap: true
|
|
8373
|
-
},
|
|
8374
|
-
optimizeDeps: {
|
|
8375
|
-
exclude: [
|
|
8376
|
-
"vitest"
|
|
8377
|
-
]
|
|
8378
8416
|
}
|
|
8379
8417
|
};
|
|
8380
8418
|
const server = await createServer(mergeConfig(config, viteOverrides));
|
|
8381
8419
|
await server.pluginContainer.buildStart({});
|
|
8382
8420
|
if (options.api === true)
|
|
8383
8421
|
options.api = defaultPort;
|
|
8384
|
-
if (options.open &&
|
|
8422
|
+
if (options.open && typeof options.api !== "number")
|
|
8385
8423
|
options.api = defaultPort;
|
|
8386
8424
|
if (typeof options.api === "number")
|
|
8387
8425
|
await server.listen(options.api);
|
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,8 @@ declare class Vitest {
|
|
|
212
212
|
constructor();
|
|
213
213
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
214
214
|
start(filters?: string[]): Promise<void>;
|
|
215
|
+
private getTestDependencies;
|
|
216
|
+
filterTestsBySource(tests: string[]): Promise<string[]>;
|
|
215
217
|
runFiles(files: string[]): Promise<void>;
|
|
216
218
|
log(...args: any[]): void;
|
|
217
219
|
error(...args: any[]): void;
|
|
@@ -369,6 +371,18 @@ interface ParsedStack {
|
|
|
369
371
|
file: string;
|
|
370
372
|
line: number;
|
|
371
373
|
column: number;
|
|
374
|
+
sourcePos?: Position;
|
|
375
|
+
}
|
|
376
|
+
interface ErrorWithDiff extends Error {
|
|
377
|
+
name: string;
|
|
378
|
+
nameStr?: string;
|
|
379
|
+
stack?: string;
|
|
380
|
+
stackStr?: string;
|
|
381
|
+
stacks?: ParsedStack[];
|
|
382
|
+
showDiff?: boolean;
|
|
383
|
+
actual?: any;
|
|
384
|
+
expected?: any;
|
|
385
|
+
operator?: string;
|
|
372
386
|
}
|
|
373
387
|
|
|
374
388
|
declare type ChainableFunction<T extends string, Args extends any[], R = any> = {
|
|
@@ -379,21 +393,19 @@ declare type ChainableFunction<T extends string, Args extends any[], R = any> =
|
|
|
379
393
|
|
|
380
394
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
381
395
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
382
|
-
declare type ComputeMode = 'serial' | 'concurrent';
|
|
383
396
|
interface TaskBase {
|
|
384
397
|
id: string;
|
|
385
398
|
name: string;
|
|
386
399
|
mode: RunMode;
|
|
387
|
-
|
|
400
|
+
concurrent?: boolean;
|
|
388
401
|
suite?: Suite;
|
|
389
402
|
file?: File;
|
|
390
403
|
result?: TaskResult;
|
|
391
404
|
}
|
|
392
405
|
interface TaskResult {
|
|
393
406
|
state: TaskState;
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
error?: unknown;
|
|
407
|
+
duration?: number;
|
|
408
|
+
error?: ErrorWithDiff;
|
|
397
409
|
}
|
|
398
410
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
399
411
|
interface Suite extends TaskBase {
|
|
@@ -402,6 +414,7 @@ interface Suite extends TaskBase {
|
|
|
402
414
|
}
|
|
403
415
|
interface File extends Suite {
|
|
404
416
|
filepath: string;
|
|
417
|
+
collectDuration?: number;
|
|
405
418
|
}
|
|
406
419
|
interface Test extends TaskBase {
|
|
407
420
|
type: 'test';
|
|
@@ -529,6 +542,20 @@ interface InlineConfig {
|
|
|
529
542
|
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
530
543
|
*/
|
|
531
544
|
inline?: (string | RegExp)[];
|
|
545
|
+
/**
|
|
546
|
+
* Interpret CJS module's default as named exports
|
|
547
|
+
*
|
|
548
|
+
* @default true
|
|
549
|
+
*/
|
|
550
|
+
interpretDefault?: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
553
|
+
* This will significantly improve the performance in huge repo, but might potentially
|
|
554
|
+
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
555
|
+
*
|
|
556
|
+
* @default true
|
|
557
|
+
*/
|
|
558
|
+
fallbackCJS?: boolean;
|
|
532
559
|
};
|
|
533
560
|
/**
|
|
534
561
|
* Register apis globally
|
|
@@ -582,7 +609,6 @@ interface InlineConfig {
|
|
|
582
609
|
* @default available CPUs
|
|
583
610
|
*/
|
|
584
611
|
minThreads?: number;
|
|
585
|
-
interpretDefault?: boolean;
|
|
586
612
|
/**
|
|
587
613
|
* Default timeout of a test in milliseconds
|
|
588
614
|
*
|
|
@@ -681,15 +707,17 @@ interface UserConfig extends InlineConfig {
|
|
|
681
707
|
/**
|
|
682
708
|
* Run tests that cover a list of source files
|
|
683
709
|
*/
|
|
684
|
-
|
|
710
|
+
related?: string[] | string;
|
|
685
711
|
}
|
|
686
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | '
|
|
712
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related'> {
|
|
687
713
|
config?: string;
|
|
688
714
|
filters?: string[];
|
|
689
715
|
testNamePattern?: RegExp;
|
|
690
|
-
|
|
716
|
+
related?: string[];
|
|
691
717
|
depsInline: (string | RegExp)[];
|
|
692
718
|
depsExternal: (string | RegExp)[];
|
|
719
|
+
fallbackCJS: boolean;
|
|
720
|
+
interpretDefault: boolean;
|
|
693
721
|
coverage: ResolvedC8Options;
|
|
694
722
|
snapshotOptions: SnapshotStateOptions;
|
|
695
723
|
}
|
|
@@ -710,9 +738,9 @@ interface WorkerRPC {
|
|
|
710
738
|
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
711
739
|
}
|
|
712
740
|
|
|
713
|
-
declare const suite: ChainableFunction<"
|
|
741
|
+
declare const suite: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
714
742
|
declare const test: TestCollector;
|
|
715
|
-
declare const describe: ChainableFunction<"
|
|
743
|
+
declare const describe: ChainableFunction<"skip" | "only" | "todo" | "concurrent", [name: string, factory?: TestFactory | undefined], SuiteCollector>;
|
|
716
744
|
declare const it: TestCollector;
|
|
717
745
|
|
|
718
746
|
declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number | undefined) => void;
|
|
@@ -794,6 +822,7 @@ interface MockWithArgs<T extends MockableFunction> extends JestMockCompatFn<Argu
|
|
|
794
822
|
(...args: ArgumentsOf<T>): ReturnType<T>;
|
|
795
823
|
}
|
|
796
824
|
declare const spies: Set<JestMockCompat<any[], any>>;
|
|
825
|
+
declare function isMockFunction(fn: any): fn is EnhancedSpy;
|
|
797
826
|
declare function spyOn<T, K extends keyof T>(obj: T, method: K, accessType?: 'get' | 'set'): T[K] extends (...args: infer TArgs) => infer TReturnValue ? JestMockCompat<TArgs, TReturnValue> : JestMockCompat;
|
|
798
827
|
declare type Awaited<T> = T extends Promise<infer R> ? R : never;
|
|
799
828
|
declare function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TArgs, R>;
|
|
@@ -871,7 +900,7 @@ declare class VitestUtils {
|
|
|
871
900
|
*/
|
|
872
901
|
mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
873
902
|
mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
874
|
-
isMockFunction(fn: any):
|
|
903
|
+
isMockFunction(fn: any): fn is EnhancedSpy;
|
|
875
904
|
clearAllMocks(): this;
|
|
876
905
|
resetAllMocks(): this;
|
|
877
906
|
restoreAllMocks(): this;
|
|
@@ -882,7 +911,13 @@ declare const vi: VitestUtils;
|
|
|
882
911
|
interface WebSocketHandlers {
|
|
883
912
|
getFiles(): File[];
|
|
884
913
|
getConfig(): ResolvedConfig;
|
|
885
|
-
|
|
914
|
+
readFile(id: string): Promise<string>;
|
|
915
|
+
writeFile(id: string, content: string): Promise<void>;
|
|
916
|
+
getModuleGraph(id: string): Promise<{
|
|
917
|
+
graph: Record<string, string[]>;
|
|
918
|
+
externalized: string[];
|
|
919
|
+
inlined: string[];
|
|
920
|
+
}>;
|
|
886
921
|
rerun(files: string[]): Promise<void>;
|
|
887
922
|
}
|
|
888
923
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onTaskUpdate'> {
|
|
@@ -977,4 +1012,4 @@ declare global {
|
|
|
977
1012
|
}
|
|
978
1013
|
}
|
|
979
1014
|
|
|
980
|
-
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment,
|
|
1015
|
+
export { ArgumentsOf, ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ConstructorArgumentsOf, DoneCallback, EnhancedSpy, Environment, EnvironmentReturn, ErrorWithDiff, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, MaybeMocked, MaybeMockedConstructor, MaybeMockedDeep, MethodKeysOf, MockWithArgs, MockableFunction, MockedFunction, MockedFunctionDeep, MockedObject, MockedObjectDeep, ModuleCache, Nullable, ParsedStack, Position, PropertyKeysOf, Reporter, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, describe, expect, fn, isMockFunction, it, spies, spyOn, suite, test, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-
|
|
3
|
-
export { f as fn, s as spies, a as spyOn } from './jest-mock-
|
|
1
|
+
export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-5ff3926d.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-4b6e78b4.js';
|
|
3
|
+
export { f as fn, i as isMockFunction, s as spies, a as spyOn } from './jest-mock-30625866.js';
|
|
4
4
|
export { assert, default as chai, should } from 'chai';
|
|
5
|
-
import './index-
|
|
5
|
+
import './index-9fdde2e8.js';
|
|
6
6
|
import 'url';
|
|
7
7
|
import 'tty';
|
|
8
8
|
import 'local-pkg';
|
|
@@ -2,6 +2,9 @@ import { util } from 'chai';
|
|
|
2
2
|
import * as tinyspy from 'tinyspy';
|
|
3
3
|
|
|
4
4
|
const spies = new Set();
|
|
5
|
+
function isMockFunction(fn2) {
|
|
6
|
+
return typeof fn2 === "function" && "__isSpy" in fn2 && fn2.__isSpy;
|
|
7
|
+
}
|
|
5
8
|
function spyOn(obj, method, accessType) {
|
|
6
9
|
const dictionary = {
|
|
7
10
|
get: "getter",
|
|
@@ -87,4 +90,4 @@ function fn(implementation) {
|
|
|
87
90
|
}) }, "fn"));
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
export { spyOn as a, fn as f, spies as s };
|
|
93
|
+
export { spyOn as a, fn as f, isMockFunction as i, spies as s };
|
package/dist/node.d.ts
CHANGED
|
@@ -122,24 +122,44 @@ interface UserConsoleLog {
|
|
|
122
122
|
type: 'stdout' | 'stderr';
|
|
123
123
|
taskId?: string;
|
|
124
124
|
}
|
|
125
|
+
interface Position {
|
|
126
|
+
line: number;
|
|
127
|
+
column: number;
|
|
128
|
+
}
|
|
129
|
+
interface ParsedStack {
|
|
130
|
+
method: string;
|
|
131
|
+
file: string;
|
|
132
|
+
line: number;
|
|
133
|
+
column: number;
|
|
134
|
+
sourcePos?: Position;
|
|
135
|
+
}
|
|
136
|
+
interface ErrorWithDiff extends Error {
|
|
137
|
+
name: string;
|
|
138
|
+
nameStr?: string;
|
|
139
|
+
stack?: string;
|
|
140
|
+
stackStr?: string;
|
|
141
|
+
stacks?: ParsedStack[];
|
|
142
|
+
showDiff?: boolean;
|
|
143
|
+
actual?: any;
|
|
144
|
+
expected?: any;
|
|
145
|
+
operator?: string;
|
|
146
|
+
}
|
|
125
147
|
|
|
126
148
|
declare type RunMode = 'run' | 'skip' | 'only' | 'todo';
|
|
127
149
|
declare type TaskState = RunMode | 'pass' | 'fail';
|
|
128
|
-
declare type ComputeMode = 'serial' | 'concurrent';
|
|
129
150
|
interface TaskBase {
|
|
130
151
|
id: string;
|
|
131
152
|
name: string;
|
|
132
153
|
mode: RunMode;
|
|
133
|
-
|
|
154
|
+
concurrent?: boolean;
|
|
134
155
|
suite?: Suite;
|
|
135
156
|
file?: File;
|
|
136
157
|
result?: TaskResult;
|
|
137
158
|
}
|
|
138
159
|
interface TaskResult {
|
|
139
160
|
state: TaskState;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
error?: unknown;
|
|
161
|
+
duration?: number;
|
|
162
|
+
error?: ErrorWithDiff;
|
|
143
163
|
}
|
|
144
164
|
declare type TaskResultPack = [id: string, result: TaskResult | undefined];
|
|
145
165
|
interface Suite extends TaskBase {
|
|
@@ -148,6 +168,7 @@ interface Suite extends TaskBase {
|
|
|
148
168
|
}
|
|
149
169
|
interface File extends Suite {
|
|
150
170
|
filepath: string;
|
|
171
|
+
collectDuration?: number;
|
|
151
172
|
}
|
|
152
173
|
interface Test extends TaskBase {
|
|
153
174
|
type: 'test';
|
|
@@ -237,6 +258,20 @@ interface InlineConfig {
|
|
|
237
258
|
* This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
|
|
238
259
|
*/
|
|
239
260
|
inline?: (string | RegExp)[];
|
|
261
|
+
/**
|
|
262
|
+
* Interpret CJS module's default as named exports
|
|
263
|
+
*
|
|
264
|
+
* @default true
|
|
265
|
+
*/
|
|
266
|
+
interpretDefault?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* When a dependency is a valid ESM package, try to guess the cjs version based on the path.
|
|
269
|
+
* This will significantly improve the performance in huge repo, but might potentially
|
|
270
|
+
* cause some misalignment if a package have different logic in ESM and CJS mode.
|
|
271
|
+
*
|
|
272
|
+
* @default true
|
|
273
|
+
*/
|
|
274
|
+
fallbackCJS?: boolean;
|
|
240
275
|
};
|
|
241
276
|
/**
|
|
242
277
|
* Register apis globally
|
|
@@ -290,7 +325,6 @@ interface InlineConfig {
|
|
|
290
325
|
* @default available CPUs
|
|
291
326
|
*/
|
|
292
327
|
minThreads?: number;
|
|
293
|
-
interpretDefault?: boolean;
|
|
294
328
|
/**
|
|
295
329
|
* Default timeout of a test in milliseconds
|
|
296
330
|
*
|
|
@@ -389,15 +423,17 @@ interface UserConfig extends InlineConfig {
|
|
|
389
423
|
/**
|
|
390
424
|
* Run tests that cover a list of source files
|
|
391
425
|
*/
|
|
392
|
-
|
|
426
|
+
related?: string[] | string;
|
|
393
427
|
}
|
|
394
|
-
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | '
|
|
428
|
+
interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'coverage' | 'testNamePattern' | 'related'> {
|
|
395
429
|
config?: string;
|
|
396
430
|
filters?: string[];
|
|
397
431
|
testNamePattern?: RegExp;
|
|
398
|
-
|
|
432
|
+
related?: string[];
|
|
399
433
|
depsInline: (string | RegExp)[];
|
|
400
434
|
depsExternal: (string | RegExp)[];
|
|
435
|
+
fallbackCJS: boolean;
|
|
436
|
+
interpretDefault: boolean;
|
|
401
437
|
coverage: ResolvedC8Options;
|
|
402
438
|
snapshotOptions: SnapshotStateOptions;
|
|
403
439
|
}
|
|
@@ -452,6 +488,8 @@ declare class Vitest {
|
|
|
452
488
|
constructor();
|
|
453
489
|
setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
|
|
454
490
|
start(filters?: string[]): Promise<void>;
|
|
491
|
+
private getTestDependencies;
|
|
492
|
+
filterTestsBySource(tests: string[]): Promise<string[]>;
|
|
455
493
|
runFiles(files: string[]): Promise<void>;
|
|
456
494
|
log(...args: any[]): void;
|
|
457
495
|
error(...args: any[]): void;
|
package/dist/node.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { c as createVitest } from './index-
|
|
2
|
-
import '
|
|
1
|
+
export { c as createVitest } from './index-e04b9e4c.js';
|
|
2
|
+
import 'fs';
|
|
3
|
+
import './index-9fdde2e8.js';
|
|
3
4
|
import 'url';
|
|
4
5
|
import 'tty';
|
|
5
6
|
import 'local-pkg';
|
|
6
7
|
import 'path';
|
|
7
8
|
import 'vite';
|
|
8
9
|
import 'process';
|
|
9
|
-
import 'fs';
|
|
10
10
|
import 'os';
|
|
11
11
|
import 'util';
|
|
12
12
|
import 'stream';
|
|
13
13
|
import 'events';
|
|
14
|
-
import './constants-
|
|
14
|
+
import './constants-8b3a9b31.js';
|
|
15
15
|
import './magic-string.es-94000aea.js';
|
|
16
16
|
import 'perf_hooks';
|
|
17
|
-
import './diff-
|
|
17
|
+
import './diff-3adb959a.js';
|
|
18
18
|
import './index-648e7ab2.js';
|
|
19
19
|
import './_commonjsHelpers-c9e3b764.js';
|
|
20
20
|
import 'assert';
|