vitest 0.21.1 → 0.22.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/LICENSE.md +32 -4
- package/dist/browser.d.ts +4 -5
- package/dist/browser.mjs +8 -9
- package/dist/{chunk-api-setup.7a6ba7fb.mjs → chunk-api-setup.ecd02c18.mjs} +8 -7
- package/dist/{chunk-constants.26dc9f85.mjs → chunk-constants.d3f8437b.mjs} +4 -4
- package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.3aa3eae6.mjs} +3 -2
- package/dist/{chunk-defaults.02abff90.mjs → chunk-integrations-coverage.d205bd87.mjs} +23 -152
- package/dist/{chunk-integrations-globals.44a8f047.mjs → chunk-integrations-globals.e81d2091.mjs} +7 -6
- package/dist/{chunk-mock-date.bc81a3ac.mjs → chunk-mock-date.debe9954.mjs} +6 -67
- package/dist/chunk-node-git.71b74da4.mjs +80 -0
- package/dist/{chunk-runtime-chain.98d42d89.mjs → chunk-runtime-chain.6e363ba2.mjs} +4 -3
- package/dist/{chunk-runtime-error.87a2b5a2.mjs → chunk-runtime-error.975bd80a.mjs} +13 -12
- package/dist/{chunk-runtime-hooks.453f8858.mjs → chunk-runtime-hooks.4789e99d.mjs} +3 -3
- package/dist/{chunk-runtime-mocker.23b62bfa.mjs → chunk-runtime-mocker.c91d29ce.mjs} +5 -5
- package/dist/{chunk-runtime-rpc.b50ab560.mjs → chunk-runtime-rpc.29488183.mjs} +1 -1
- package/dist/{chunk-utils-source-map.94107ee8.mjs → chunk-utils-source-map.2a082ffd.mjs} +2 -1
- package/dist/{chunk-vite-node-client.fdd9592c.mjs → chunk-vite-node-client.d1ead698.mjs} +2 -2
- package/dist/{chunk-vite-node-debug.09afb76f.mjs → chunk-vite-node-debug.ff1d2a9f.mjs} +3 -2
- package/dist/{chunk-vite-node-externalize.27aee038.mjs → chunk-vite-node-externalize.3a38c8af.mjs} +153 -35
- package/dist/{chunk-vite-node-utils.f34df9d3.mjs → chunk-vite-node-utils.d8e5ff7b.mjs} +42 -8
- package/dist/cli-wrapper.mjs +107 -0
- package/dist/cli.mjs +15 -13
- package/dist/config.cjs +3 -0
- package/dist/config.d.ts +6 -3
- package/dist/config.mjs +2 -1
- package/dist/entry.mjs +8 -9
- package/dist/{global-60f880c6.d.ts → global-74489cc9.d.ts} +485 -166
- package/dist/{index-4a906fa4.d.ts → index-9eded9ec.d.ts} +2 -50
- package/dist/index.d.ts +5 -6
- package/dist/index.mjs +6 -5
- package/dist/loader.mjs +3 -2
- package/dist/node.d.ts +3 -3
- package/dist/node.mjs +14 -12
- package/dist/suite.mjs +5 -4
- package/dist/{vendor-index.61438b77.mjs → vendor-index.29636037.mjs} +1 -61
- package/dist/{vendor-index.62ce5c33.mjs → vendor-index.2ae8040a.mjs} +0 -0
- package/dist/vendor-index.9d9196cc.mjs +61 -0
- package/dist/{chunk-node-git.c2be9c49.mjs → vendor-index.fbec8a81.mjs} +5 -73
- package/dist/vendor-picocolors.807856aa.mjs +64 -0
- package/dist/worker.mjs +7 -6
- package/package.json +6 -10
- package/vitest.mjs +1 -1
- package/dist/mocker-5e2a8e41.d.ts +0 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { e as environments, t as
|
|
2
|
-
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.
|
|
3
|
-
import { h as deepClone, k as getType, l as isNode, R as RealDate, t as toArray, o as relativePath,
|
|
4
|
-
import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.
|
|
5
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
1
|
+
import { e as environments, t as takeCoverageInsideWorker, p as pLimit } from './chunk-integrations-coverage.d205bd87.mjs';
|
|
2
|
+
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.4789e99d.mjs';
|
|
3
|
+
import { h as deepClone, k as getType, l as isNode, R as RealDate, t as toArray, o as relativePath, p as isBrowser, q as partitionSuiteChildren, u as shuffle, v as hasTests, w as hasFailed, e as getFullName } from './chunk-mock-date.debe9954.mjs';
|
|
4
|
+
import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.6e363ba2.mjs';
|
|
5
|
+
import { r as rpc } from './chunk-runtime-rpc.29488183.mjs';
|
|
6
6
|
import util$1 from 'util';
|
|
7
7
|
import { util } from 'chai';
|
|
8
|
-
import { s as stringify } from './chunk-utils-source-map.
|
|
8
|
+
import { s as stringify } from './chunk-utils-source-map.2a082ffd.mjs';
|
|
9
9
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
10
10
|
import { a as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.b48455ed.mjs';
|
|
11
11
|
|
|
@@ -131,7 +131,7 @@ async function setupGlobalEnv(config) {
|
|
|
131
131
|
if (isNode)
|
|
132
132
|
await setupConsoleLogSpy();
|
|
133
133
|
if (config.globals)
|
|
134
|
-
(await import('./chunk-integrations-globals.
|
|
134
|
+
(await import('./chunk-integrations-globals.e81d2091.mjs')).registerApiGlobally();
|
|
135
135
|
}
|
|
136
136
|
function setupDefines(defines) {
|
|
137
137
|
for (const key in defines)
|
|
@@ -442,7 +442,7 @@ async function sendTasksUpdate() {
|
|
|
442
442
|
async function runTest(test) {
|
|
443
443
|
var _a, _b;
|
|
444
444
|
if (test.mode !== "run") {
|
|
445
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
445
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
|
|
446
446
|
getSnapshotClient().skipTestSnapshots(test);
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
@@ -458,7 +458,7 @@ async function runTest(test) {
|
|
|
458
458
|
updateTask(test);
|
|
459
459
|
clearModuleMocks();
|
|
460
460
|
if (isNode) {
|
|
461
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
461
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
|
|
462
462
|
await getSnapshotClient().setTest(test);
|
|
463
463
|
}
|
|
464
464
|
const workerState = getWorkerState();
|
|
@@ -511,7 +511,7 @@ async function runTest(test) {
|
|
|
511
511
|
if (isBrowser && test.result.error)
|
|
512
512
|
console.error(test.result.error.message, test.result.error.stackStr);
|
|
513
513
|
if (isNode) {
|
|
514
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
514
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
|
|
515
515
|
getSnapshotClient().clearTest();
|
|
516
516
|
}
|
|
517
517
|
test.result.duration = now() - start;
|
|
@@ -623,10 +623,11 @@ async function startTestsBrowser(paths, config) {
|
|
|
623
623
|
async function startTestsNode(paths, config) {
|
|
624
624
|
const files = await collectTests(paths, config);
|
|
625
625
|
rpc().onCollected(files);
|
|
626
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
626
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.6e363ba2.mjs').then(function (n) { return n.p; });
|
|
627
627
|
getSnapshotClient().clear();
|
|
628
628
|
await runFiles(files, config);
|
|
629
|
-
|
|
629
|
+
const coverage = await takeCoverageInsideWorker(config.coverage);
|
|
630
|
+
rpc().onAfterSuiteRun({ coverage });
|
|
630
631
|
await getSnapshotClient().saveCurrent();
|
|
631
632
|
await sendTasksUpdate();
|
|
632
633
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.
|
|
2
|
-
import { R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.6e363ba2.mjs';
|
|
2
|
+
import { R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.debe9954.mjs';
|
|
3
3
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
4
|
-
import { p as parseStacktrace } from './chunk-utils-source-map.
|
|
4
|
+
import { p as parseStacktrace } from './chunk-utils-source-map.2a082ffd.mjs';
|
|
5
5
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
6
6
|
import util from 'util';
|
|
7
7
|
import { spyOn, fn, isMockFunction, spies } from './spy.mjs';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { V as ViteNodeRunner } from './chunk-vite-node-client.
|
|
1
|
+
import { V as ViteNodeRunner } from './chunk-vite-node-client.d1ead698.mjs';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
|
-
import {
|
|
3
|
+
import { L as isWindows, M as mergeSlashes, d as dirname, j as join, y as basename, x as resolve, s as slash, k as getType, N as getAllMockableProperties } from './chunk-mock-date.debe9954.mjs';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
|
5
|
-
import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.
|
|
6
|
-
import { d as distDir } from './chunk-constants.
|
|
5
|
+
import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.d8e5ff7b.mjs';
|
|
6
|
+
import { d as distDir } from './chunk-constants.d3f8437b.mjs';
|
|
7
7
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
8
8
|
|
|
9
9
|
class RefTracker {
|
|
@@ -87,7 +87,7 @@ const _VitestMocker = class {
|
|
|
87
87
|
if (prop === "then") {
|
|
88
88
|
if (target instanceof Promise)
|
|
89
89
|
return target.then.bind(target);
|
|
90
|
-
} else if (
|
|
90
|
+
} else if (!(prop in target)) {
|
|
91
91
|
throw new Error(`[vitest] No "${prop}" export is defined on the "${dep}"`);
|
|
92
92
|
}
|
|
93
93
|
return val;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
|
-
import {
|
|
5
|
-
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.
|
|
4
|
+
import { x as resolve, d as dirname, z as isAbsolute, K as extname } from './chunk-mock-date.debe9954.mjs';
|
|
5
|
+
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.d8e5ff7b.mjs';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
7
|
|
|
8
8
|
const debugExecute = createDebug("vite-node:client:execute");
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
|
-
import {
|
|
2
|
+
import { x as resolve, j as join } from './chunk-mock-date.debe9954.mjs';
|
|
3
|
+
import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
|
|
3
4
|
import 'path';
|
|
4
|
-
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
|
+
import 'tty';
|
|
6
7
|
|
|
7
8
|
function hashCode(s) {
|
|
8
9
|
return s.split("").reduce((a, b) => {
|
package/dist/{chunk-vite-node-externalize.27aee038.mjs → chunk-vite-node-externalize.3a38c8af.mjs}
RENAMED
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as pLimit,
|
|
1
|
+
import { x as resolve, j as join, y as basename, d as dirname, A as AggregateErrorPonyfill, z as isAbsolute, B as relative, s as slash$2, l as isNode, o as relativePath, C as getTests, e as getFullName, w as hasFailed, D as hasFailedSnapshot, E as getSuites, u as shuffle, t as toArray$1, F as normalize, n as noop$1, G as deepMerge, H as toNamespacedPath, g as getCallLastIndex, f as notNullish, I as ensurePackageInstalled, J as stdout } from './chunk-mock-date.debe9954.mjs';
|
|
2
|
+
import { p as pLimit, g as getCoverageProvider, a as envPackageNames, C as CoverageProviderMap } from './chunk-integrations-coverage.d205bd87.mjs';
|
|
3
3
|
import { loadConfigFromFile, createServer, mergeConfig } from 'vite';
|
|
4
4
|
import path$a from 'path';
|
|
5
|
-
import
|
|
5
|
+
import url, { fileURLToPath } from 'url';
|
|
6
6
|
import process$1 from 'process';
|
|
7
7
|
import fs$8, { promises, existsSync, readFileSync } from 'fs';
|
|
8
|
-
import { d as distDir, r as rootDir, c as configFiles, a as defaultPort } from './chunk-constants.
|
|
8
|
+
import { d as distDir, r as rootDir, c as configFiles, a as defaultPort } from './chunk-constants.d3f8437b.mjs';
|
|
9
9
|
import require$$0, { cpus, hostname } from 'os';
|
|
10
10
|
import util$2 from 'util';
|
|
11
11
|
import require$$0$1 from 'stream';
|
|
12
12
|
import require$$2 from 'events';
|
|
13
13
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
14
|
-
import {
|
|
14
|
+
import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
|
|
15
|
+
import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.d1ead698.mjs';
|
|
15
16
|
import createDebug from 'debug';
|
|
16
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.
|
|
17
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.d8e5ff7b.mjs';
|
|
17
18
|
import { MessageChannel } from 'worker_threads';
|
|
18
19
|
import { Tinypool } from 'tinypool';
|
|
19
20
|
import { performance } from 'perf_hooks';
|
|
20
|
-
import { c as stripAnsi, d as cliTruncate, p as parseStacktrace, e as stringWidth, h as ansiStyles, i as sliceAnsi, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, b as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.
|
|
21
|
+
import { c as stripAnsi, d as cliTruncate, p as parseStacktrace, e as stringWidth, h as ansiStyles, i as sliceAnsi, j as interpretSourcePos, s as stringify$5, u as unifiedDiff, b as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.2a082ffd.mjs';
|
|
21
22
|
import { b as safeSetInterval, c as safeClearInterval, s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
|
|
22
23
|
import { resolveModule } from 'local-pkg';
|
|
23
24
|
import { createHash } from 'crypto';
|
|
24
|
-
import { o as onetime
|
|
25
|
+
import { o as onetime } from './vendor-index.9d9196cc.mjs';
|
|
26
|
+
import { s as signalExit } from './vendor-index.29636037.mjs';
|
|
25
27
|
import MagicString from './chunk-magic-string.efe26975.mjs';
|
|
26
28
|
import require$$0$2 from 'readline';
|
|
27
29
|
import { p as prompts } from './vendor-index.ae96af6e.mjs';
|
|
28
30
|
|
|
29
|
-
var version$1 = "0.
|
|
31
|
+
var version$1 = "0.22.0";
|
|
30
32
|
|
|
31
33
|
class EndError extends Error {
|
|
32
34
|
constructor(value) {
|
|
@@ -6850,7 +6852,7 @@ class ViteNodeServer {
|
|
|
6850
6852
|
}, options.debug ?? {});
|
|
6851
6853
|
}
|
|
6852
6854
|
if (options.debug)
|
|
6853
|
-
import('./chunk-vite-node-debug.
|
|
6855
|
+
import('./chunk-vite-node-debug.ff1d2a9f.mjs').then((r) => this.debugger = new r.Debugger(server.config.root, options.debug));
|
|
6854
6856
|
}
|
|
6855
6857
|
shouldExternalize(id) {
|
|
6856
6858
|
return shouldExternalize(id, this.options.deps, this.externalizeCache);
|
|
@@ -7000,11 +7002,11 @@ function addSnapshotResult(summary, result) {
|
|
|
7000
7002
|
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
7001
7003
|
}
|
|
7002
7004
|
|
|
7003
|
-
const workerPath =
|
|
7004
|
-
const loaderPath =
|
|
7005
|
+
const workerPath = url.pathToFileURL(resolve(distDir, "./worker.mjs")).href;
|
|
7006
|
+
const loaderPath = url.pathToFileURL(resolve(distDir, "./loader.mjs")).href;
|
|
7005
7007
|
const suppressLoaderWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
7006
7008
|
function createPool(ctx) {
|
|
7007
|
-
var _a, _b;
|
|
7009
|
+
var _a, _b, _c;
|
|
7008
7010
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(cpus().length / 2), 1) : Math.max(cpus().length - 1, 1);
|
|
7009
7011
|
const maxThreads = ctx.config.maxThreads ?? threadsCount;
|
|
7010
7012
|
const minThreads = ctx.config.minThreads ?? threadsCount;
|
|
@@ -7031,8 +7033,7 @@ function createPool(ctx) {
|
|
|
7031
7033
|
options.maxThreads = 1;
|
|
7032
7034
|
options.minThreads = 1;
|
|
7033
7035
|
}
|
|
7034
|
-
|
|
7035
|
-
(_b = process.env).NODE_V8_COVERAGE || (_b.NODE_V8_COVERAGE = ctx.config.coverage.tempDirectory);
|
|
7036
|
+
(_c = (_b = ctx.coverageProvider) == null ? void 0 : _b.onBeforeFilesRun) == null ? void 0 : _c.call(_b);
|
|
7036
7037
|
options.env = {
|
|
7037
7038
|
TEST: "true",
|
|
7038
7039
|
VITEST: "true",
|
|
@@ -7122,6 +7123,10 @@ function createChannel(ctx) {
|
|
|
7122
7123
|
ctx.state.collectFiles(files);
|
|
7123
7124
|
ctx.report("onCollected", files);
|
|
7124
7125
|
},
|
|
7126
|
+
onAfterSuiteRun(meta) {
|
|
7127
|
+
var _a;
|
|
7128
|
+
(_a = ctx.coverageProvider) == null ? void 0 : _a.onAfterSuiteRun(meta);
|
|
7129
|
+
},
|
|
7125
7130
|
onTaskUpdate(packs) {
|
|
7126
7131
|
ctx.state.updateTasks(packs);
|
|
7127
7132
|
ctx.report("onTaskUpdate", packs);
|
|
@@ -8065,7 +8070,8 @@ function escapeXML(value) {
|
|
|
8065
8070
|
}
|
|
8066
8071
|
function getDuration(task) {
|
|
8067
8072
|
var _a;
|
|
8068
|
-
|
|
8073
|
+
const duration = ((_a = task.result) == null ? void 0 : _a.duration) ?? 0;
|
|
8074
|
+
return (duration / 1e3).toLocaleString(void 0, { useGrouping: false, maximumFractionDigits: 10 });
|
|
8069
8075
|
}
|
|
8070
8076
|
class JUnitReporter {
|
|
8071
8077
|
async onInit(ctx) {
|
|
@@ -8349,6 +8355,85 @@ class StateManager {
|
|
|
8349
8355
|
}
|
|
8350
8356
|
}
|
|
8351
8357
|
|
|
8358
|
+
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
8359
|
+
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
|
|
8360
|
+
const defaultCoverageExcludes = [
|
|
8361
|
+
"coverage/**",
|
|
8362
|
+
"dist/**",
|
|
8363
|
+
"packages/*/test{,s}/**",
|
|
8364
|
+
"**/*.d.ts",
|
|
8365
|
+
"cypress/**",
|
|
8366
|
+
"test{,s}/**",
|
|
8367
|
+
"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
|
|
8368
|
+
"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
|
|
8369
|
+
"**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
|
|
8370
|
+
"**/__tests__/**",
|
|
8371
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.{js,cjs,mjs,ts}",
|
|
8372
|
+
"**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
|
|
8373
|
+
];
|
|
8374
|
+
const coverageConfigDefaults = {
|
|
8375
|
+
provider: "c8",
|
|
8376
|
+
enabled: false,
|
|
8377
|
+
clean: true,
|
|
8378
|
+
cleanOnRerun: false,
|
|
8379
|
+
reportsDirectory: "./coverage",
|
|
8380
|
+
excludeNodeModules: true,
|
|
8381
|
+
exclude: defaultCoverageExcludes,
|
|
8382
|
+
reporter: ["text", "html", "clover"],
|
|
8383
|
+
allowExternal: false,
|
|
8384
|
+
extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
|
|
8385
|
+
};
|
|
8386
|
+
const fakeTimersDefaults = {
|
|
8387
|
+
loopLimit: 1e4,
|
|
8388
|
+
shouldClearNativeTimers: true,
|
|
8389
|
+
toFake: [
|
|
8390
|
+
"setTimeout",
|
|
8391
|
+
"clearTimeout",
|
|
8392
|
+
"setInterval",
|
|
8393
|
+
"clearInterval",
|
|
8394
|
+
"setImmediate",
|
|
8395
|
+
"clearImmediate",
|
|
8396
|
+
"Date"
|
|
8397
|
+
]
|
|
8398
|
+
};
|
|
8399
|
+
const config = {
|
|
8400
|
+
allowOnly: !process.env.CI,
|
|
8401
|
+
watch: !process.env.CI,
|
|
8402
|
+
globals: false,
|
|
8403
|
+
environment: "node",
|
|
8404
|
+
threads: true,
|
|
8405
|
+
clearMocks: false,
|
|
8406
|
+
restoreMocks: false,
|
|
8407
|
+
mockReset: false,
|
|
8408
|
+
include: defaultInclude,
|
|
8409
|
+
exclude: defaultExclude,
|
|
8410
|
+
testTimeout: 5e3,
|
|
8411
|
+
hookTimeout: 1e4,
|
|
8412
|
+
teardownTimeout: 1e3,
|
|
8413
|
+
isolate: true,
|
|
8414
|
+
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
8415
|
+
forceRerunTriggers: [
|
|
8416
|
+
"**/package.json/**",
|
|
8417
|
+
"**/vitest.config.*/**",
|
|
8418
|
+
"**/vite.config.*/**"
|
|
8419
|
+
],
|
|
8420
|
+
update: false,
|
|
8421
|
+
reporters: [],
|
|
8422
|
+
silent: false,
|
|
8423
|
+
api: false,
|
|
8424
|
+
ui: false,
|
|
8425
|
+
uiBase: "/__vitest__/",
|
|
8426
|
+
open: true,
|
|
8427
|
+
css: {
|
|
8428
|
+
include: [/\.module\./]
|
|
8429
|
+
},
|
|
8430
|
+
coverage: coverageConfigDefaults,
|
|
8431
|
+
fakeTimers: fakeTimersDefaults,
|
|
8432
|
+
maxConcurrency: 5,
|
|
8433
|
+
dangerouslyIgnoreUnhandledErrors: false
|
|
8434
|
+
};
|
|
8435
|
+
const configDefaults = Object.freeze(config);
|
|
8436
|
+
|
|
8352
8437
|
class FilesStatsCache {
|
|
8353
8438
|
constructor() {
|
|
8354
8439
|
this.cache = /* @__PURE__ */ new Map();
|
|
@@ -8557,7 +8642,6 @@ function resolveConfig(options, viteConfig) {
|
|
|
8557
8642
|
};
|
|
8558
8643
|
if (viteConfig.base !== "/")
|
|
8559
8644
|
resolved.base = viteConfig.base;
|
|
8560
|
-
resolved.coverage = resolveC8Options(options.coverage || {}, resolved.root);
|
|
8561
8645
|
if (options.shard) {
|
|
8562
8646
|
if (resolved.watch)
|
|
8563
8647
|
throw new Error("You cannot use --shard option with enabled watch");
|
|
@@ -9106,7 +9190,7 @@ createLogUpdate(process$1.stdout);
|
|
|
9106
9190
|
|
|
9107
9191
|
createLogUpdate(process$1.stderr);
|
|
9108
9192
|
|
|
9109
|
-
var version = "0.
|
|
9193
|
+
var version = "0.22.0";
|
|
9110
9194
|
|
|
9111
9195
|
function fileFromParsedStack(stack) {
|
|
9112
9196
|
var _a, _b;
|
|
@@ -9349,12 +9433,14 @@ class Logger {
|
|
|
9349
9433
|
this.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
|
|
9350
9434
|
else if (this.ctx.config.api)
|
|
9351
9435
|
this.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((_c = this.ctx.config.api) == null ? void 0 : _c.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.config.api.port}`)}`)));
|
|
9436
|
+
if (this.ctx.coverageProvider)
|
|
9437
|
+
this.log(picocolors.exports.dim(" Coverage enabled with ") + picocolors.exports.yellow(this.ctx.coverageProvider.name));
|
|
9352
9438
|
this.log();
|
|
9353
9439
|
}
|
|
9354
9440
|
async printUnhandledErrors(errors) {
|
|
9355
9441
|
const errorMessage = picocolors.exports.red(picocolors.exports.bold(`
|
|
9356
|
-
Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run.
|
|
9357
|
-
|
|
9442
|
+
Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run.
|
|
9443
|
+
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.`));
|
|
9358
9444
|
this.log(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Unhandled Errors ")))));
|
|
9359
9445
|
this.log(errorMessage);
|
|
9360
9446
|
await Promise.all(errors.map(async (err) => {
|
|
@@ -9384,7 +9470,7 @@ class Vitest {
|
|
|
9384
9470
|
this.logger = new Logger(this);
|
|
9385
9471
|
}
|
|
9386
9472
|
async setServer(options, server) {
|
|
9387
|
-
var _a, _b;
|
|
9473
|
+
var _a, _b, _c;
|
|
9388
9474
|
(_a = this.unregisterWatcher) == null ? void 0 : _a.call(this);
|
|
9389
9475
|
safeClearTimeout(this._rerunTimer);
|
|
9390
9476
|
this.restartsCount += 1;
|
|
@@ -9413,8 +9499,7 @@ class Vitest {
|
|
|
9413
9499
|
this.reporters = await createReporters(resolved.reporters, this.runner);
|
|
9414
9500
|
this.runningPromise = void 0;
|
|
9415
9501
|
this._onRestartListeners.forEach((fn) => fn());
|
|
9416
|
-
|
|
9417
|
-
await cleanCoverage(resolved.coverage, resolved.coverage.clean);
|
|
9502
|
+
await ((_c = this.coverageProvider) == null ? void 0 : _c.clean(this.config.coverage.clean));
|
|
9418
9503
|
this.cache.results.setConfig(resolved.root, resolved.cache);
|
|
9419
9504
|
try {
|
|
9420
9505
|
await this.cache.results.readFromCache();
|
|
@@ -9422,6 +9507,16 @@ class Vitest {
|
|
|
9422
9507
|
this.logger.error(`[vitest] Error, while trying to parse cache in ${this.cache.results.getCachePath()}:`, err);
|
|
9423
9508
|
}
|
|
9424
9509
|
}
|
|
9510
|
+
async initCoverageProvider() {
|
|
9511
|
+
if (this.coverageProvider !== void 0)
|
|
9512
|
+
return;
|
|
9513
|
+
this.coverageProvider = await getCoverageProvider(this.config.coverage);
|
|
9514
|
+
if (this.coverageProvider) {
|
|
9515
|
+
await this.coverageProvider.initialize(this);
|
|
9516
|
+
this.config.coverage = this.coverageProvider.resolveOptions();
|
|
9517
|
+
}
|
|
9518
|
+
return this.coverageProvider;
|
|
9519
|
+
}
|
|
9425
9520
|
getSerializableConfig() {
|
|
9426
9521
|
return deepMerge({
|
|
9427
9522
|
...this.config,
|
|
@@ -9438,6 +9533,12 @@ class Vitest {
|
|
|
9438
9533
|
}, this.configOverride || {});
|
|
9439
9534
|
}
|
|
9440
9535
|
async start(filters) {
|
|
9536
|
+
try {
|
|
9537
|
+
await this.initCoverageProvider();
|
|
9538
|
+
} catch (e) {
|
|
9539
|
+
this.logger.error(e);
|
|
9540
|
+
process.exit(1);
|
|
9541
|
+
}
|
|
9441
9542
|
await this.report("onInit", this);
|
|
9442
9543
|
const files = await this.filterTestsBySource(await this.globTestFiles(filters));
|
|
9443
9544
|
if (!files.length) {
|
|
@@ -9447,8 +9548,10 @@ class Vitest {
|
|
|
9447
9548
|
}
|
|
9448
9549
|
await Promise.all(files.map((file) => this.cache.stats.updateStats(file)));
|
|
9449
9550
|
await this.runFiles(files);
|
|
9450
|
-
if (this.
|
|
9451
|
-
|
|
9551
|
+
if (this.coverageProvider) {
|
|
9552
|
+
this.logger.log(picocolors.exports.blue(" % ") + picocolors.exports.dim("Coverage report from ") + picocolors.exports.yellow(this.coverageProvider.name));
|
|
9553
|
+
await this.coverageProvider.reportCoverage();
|
|
9554
|
+
}
|
|
9452
9555
|
if (this.config.watch && !this.config.browser)
|
|
9453
9556
|
await this.report("onWatcherStart");
|
|
9454
9557
|
}
|
|
@@ -9473,7 +9576,7 @@ class Vitest {
|
|
|
9473
9576
|
}
|
|
9474
9577
|
async filterTestsBySource(tests) {
|
|
9475
9578
|
if (this.config.changed && !this.config.related) {
|
|
9476
|
-
const { VitestGit } = await import('./chunk-node-git.
|
|
9579
|
+
const { VitestGit } = await import('./chunk-node-git.71b74da4.mjs');
|
|
9477
9580
|
const vitestGit = new VitestGit(this.config.root);
|
|
9478
9581
|
const related2 = await vitestGit.findChangedFiles({
|
|
9479
9582
|
changedSince: this.config.changed
|
|
@@ -9568,6 +9671,7 @@ class Vitest {
|
|
|
9568
9671
|
if (this.restartsCount !== currentCount)
|
|
9569
9672
|
return;
|
|
9570
9673
|
this._rerunTimer = safeSetTimeout(async () => {
|
|
9674
|
+
var _a;
|
|
9571
9675
|
if (this.changedTests.size === 0) {
|
|
9572
9676
|
this.invalidates.clear();
|
|
9573
9677
|
return;
|
|
@@ -9578,12 +9682,11 @@ class Vitest {
|
|
|
9578
9682
|
this.snapshot.clear();
|
|
9579
9683
|
const files = Array.from(this.changedTests);
|
|
9580
9684
|
this.changedTests.clear();
|
|
9581
|
-
if (this.
|
|
9582
|
-
await
|
|
9685
|
+
if (this.coverageProvider && this.config.coverage.cleanOnRerun)
|
|
9686
|
+
await this.coverageProvider.clean();
|
|
9583
9687
|
await this.report("onWatcherRerun", files, triggerId);
|
|
9584
9688
|
await this.runFiles(files);
|
|
9585
|
-
|
|
9586
|
-
await reportCoverage(this);
|
|
9689
|
+
await ((_a = this.coverageProvider) == null ? void 0 : _a.reportCoverage());
|
|
9587
9690
|
if (!this.config.browser)
|
|
9588
9691
|
await this.report("onWatcherStart");
|
|
9589
9692
|
}, WATCHER_DEBOUNCE);
|
|
@@ -9959,6 +10062,16 @@ function CSSEnablerPlugin(ctx) {
|
|
|
9959
10062
|
};
|
|
9960
10063
|
}
|
|
9961
10064
|
|
|
10065
|
+
function CoverageTransform(ctx) {
|
|
10066
|
+
return {
|
|
10067
|
+
name: "vitest:coverage-transform",
|
|
10068
|
+
transform(srcCode, id) {
|
|
10069
|
+
var _a, _b;
|
|
10070
|
+
return (_b = (_a = ctx.coverageProvider) == null ? void 0 : _a.onFileTransform) == null ? void 0 : _b.call(_a, srcCode, id, this);
|
|
10071
|
+
}
|
|
10072
|
+
};
|
|
10073
|
+
}
|
|
10074
|
+
|
|
9962
10075
|
async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
9963
10076
|
let haveStarted = false;
|
|
9964
10077
|
async function UIPlugin() {
|
|
@@ -10062,7 +10175,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10062
10175
|
await ctx.setServer(options, server);
|
|
10063
10176
|
haveStarted = true;
|
|
10064
10177
|
if (options.api && options.watch)
|
|
10065
|
-
(await import('./chunk-api-setup.
|
|
10178
|
+
(await import('./chunk-api-setup.ecd02c18.mjs')).setup(ctx);
|
|
10066
10179
|
} catch (err) {
|
|
10067
10180
|
ctx.logger.printError(err, true);
|
|
10068
10181
|
process.exit(1);
|
|
@@ -10076,6 +10189,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10076
10189
|
GlobalSetupPlugin(ctx),
|
|
10077
10190
|
...options.browser ? await BrowserPlugin() : [],
|
|
10078
10191
|
CSSEnablerPlugin(ctx),
|
|
10192
|
+
CoverageTransform(ctx),
|
|
10079
10193
|
options.ui ? await UIPlugin() : null
|
|
10080
10194
|
].filter(notNullish);
|
|
10081
10195
|
}
|
|
@@ -10124,7 +10238,7 @@ function registerConsoleShortcuts(ctx) {
|
|
|
10124
10238
|
if (name === "u")
|
|
10125
10239
|
return ctx.updateSnapshot();
|
|
10126
10240
|
if (name === "a" || name === "return")
|
|
10127
|
-
return ctx.
|
|
10241
|
+
return ctx.changeNamePattern("");
|
|
10128
10242
|
if (name === "f")
|
|
10129
10243
|
return ctx.rerunFailed();
|
|
10130
10244
|
if (name === "t")
|
|
@@ -10183,9 +10297,13 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
10183
10297
|
options.coverage = { enabled: options.coverage };
|
|
10184
10298
|
const ctx = await createVitest(options, viteOverrides);
|
|
10185
10299
|
if (ctx.config.coverage.enabled) {
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10300
|
+
const provider = ctx.config.coverage.provider || "c8";
|
|
10301
|
+
if (typeof provider === "string") {
|
|
10302
|
+
const requiredPackages = CoverageProviderMap[provider];
|
|
10303
|
+
if (!await ensurePackageInstalled(requiredPackages, root)) {
|
|
10304
|
+
process.exitCode = 1;
|
|
10305
|
+
return false;
|
|
10306
|
+
}
|
|
10189
10307
|
}
|
|
10190
10308
|
}
|
|
10191
10309
|
if (ctx.config.environment && ctx.config.environment !== "node") {
|
|
@@ -4,7 +4,7 @@ import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'u
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import assert from 'assert';
|
|
6
6
|
import { format, inspect } from 'util';
|
|
7
|
-
import {
|
|
7
|
+
import { x as resolve$1 } from './chunk-mock-date.debe9954.mjs';
|
|
8
8
|
|
|
9
9
|
// This file was generated. Do not modify manually!
|
|
10
10
|
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
|
@@ -5553,13 +5553,47 @@ Parser.acorn = {
|
|
|
5553
5553
|
nonASCIIwhitespace: nonASCIIwhitespace
|
|
5554
5554
|
};
|
|
5555
5555
|
|
|
5556
|
+
const TRAILING_SLASH_RE = /\/$|\/\?/;
|
|
5557
|
+
function hasTrailingSlash(input = "", queryParams = false) {
|
|
5558
|
+
if (!queryParams) {
|
|
5559
|
+
return input.endsWith("/");
|
|
5560
|
+
}
|
|
5561
|
+
return TRAILING_SLASH_RE.test(input);
|
|
5562
|
+
}
|
|
5563
|
+
function withTrailingSlash(input = "", queryParams = false) {
|
|
5564
|
+
if (!queryParams) {
|
|
5565
|
+
return input.endsWith("/") ? input : input + "/";
|
|
5566
|
+
}
|
|
5567
|
+
if (hasTrailingSlash(input, true)) {
|
|
5568
|
+
return input || "/";
|
|
5569
|
+
}
|
|
5570
|
+
const [s0, ...s] = input.split("?");
|
|
5571
|
+
return s0 + "/" + (s.length ? `?${s.join("?")}` : "");
|
|
5572
|
+
}
|
|
5573
|
+
function hasLeadingSlash(input = "") {
|
|
5574
|
+
return input.startsWith("/");
|
|
5575
|
+
}
|
|
5576
|
+
function withoutLeadingSlash(input = "") {
|
|
5577
|
+
return (hasLeadingSlash(input) ? input.substr(1) : input) || "/";
|
|
5578
|
+
}
|
|
5579
|
+
function isNonEmptyURL(url) {
|
|
5580
|
+
return url && url !== "/";
|
|
5581
|
+
}
|
|
5582
|
+
function joinURL(base, ...input) {
|
|
5583
|
+
let url = base || "";
|
|
5584
|
+
for (const i of input.filter(isNonEmptyURL)) {
|
|
5585
|
+
url = url ? withTrailingSlash(url) + withoutLeadingSlash(i) : i;
|
|
5586
|
+
}
|
|
5587
|
+
return url;
|
|
5588
|
+
}
|
|
5589
|
+
|
|
5556
5590
|
function normalizeWindowsPath$1(input = "") {
|
|
5557
|
-
if (!input.includes("\\")) {
|
|
5591
|
+
if (!input || !input.includes("\\")) {
|
|
5558
5592
|
return input;
|
|
5559
5593
|
}
|
|
5560
5594
|
return input.replace(/\\/g, "/");
|
|
5561
5595
|
}
|
|
5562
|
-
const _IS_ABSOLUTE_RE$1 =
|
|
5596
|
+
const _IS_ABSOLUTE_RE$1 = /^[\\/](?![\\/])|^[\\/]{2}(?!\.)|^[a-zA-Z]:[\\/]/;
|
|
5563
5597
|
const isAbsolute$1 = function(p) {
|
|
5564
5598
|
return _IS_ABSOLUTE_RE$1.test(p);
|
|
5565
5599
|
};
|
|
@@ -6710,7 +6744,7 @@ function normalizeid(id) {
|
|
|
6710
6744
|
if (BUILTIN_MODULES.has(id)) {
|
|
6711
6745
|
return "node:" + id;
|
|
6712
6746
|
}
|
|
6713
|
-
return "file://" + normalizeSlash(id);
|
|
6747
|
+
return "file://" + encodeURI(normalizeSlash(id));
|
|
6714
6748
|
}
|
|
6715
6749
|
function isNodeBuiltin(id = "") {
|
|
6716
6750
|
id = id.replace(/^node:/, "").split("/")[0];
|
|
@@ -6754,10 +6788,10 @@ function _resolve(id, opts = {}) {
|
|
|
6754
6788
|
}
|
|
6755
6789
|
const urls = [..._urls];
|
|
6756
6790
|
for (const url of _urls) {
|
|
6757
|
-
if (url.protocol === "file:"
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
urls.push(
|
|
6791
|
+
if (url.protocol === "file:") {
|
|
6792
|
+
urls.push(new URL("./", url));
|
|
6793
|
+
urls.push(new URL(joinURL(url.pathname, "_index.js"), url));
|
|
6794
|
+
urls.push(new URL("./node_modules", url));
|
|
6761
6795
|
}
|
|
6762
6796
|
}
|
|
6763
6797
|
let resolved;
|