vitest 2.0.0-beta.1 → 2.0.0-beta.11
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 +1 -1
- package/dist/browser.d.ts +22 -2
- package/dist/browser.js +5 -3
- package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.CC2ed6Py.js} +9 -9
- package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
- package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.Ckl0vEQr.js} +76 -31
- package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.BXW_BJeO.js} +40 -32
- package/dist/cli.js +3 -3
- package/dist/config.cjs +43 -20
- package/dist/config.d.ts +2 -2
- package/dist/config.js +43 -21
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +125 -37
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +20 -30
- package/dist/index.js +9 -9
- package/dist/node.d.ts +22 -9
- package/dist/node.js +25 -15
- package/dist/path.js +4 -1
- package/dist/{reporters-MGvT5U9f.d.ts → reporters-fiIq_dT9.d.ts} +310 -148
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +4 -2
- package/dist/runners.js +103 -57
- package/dist/{suite-8WAe-urM.d.ts → suite-D4aoU9rI.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -2
- package/dist/utils.d.ts +1 -5
- package/dist/utils.js +1 -6
- package/dist/vendor/{base.VFkIJ66g.js → base.C2DbLEfT.js} +4 -3
- package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.CMp8QfyL.js} +13 -14
- package/dist/vendor/{cac.DzKZaJu2.js → cac.BcJW7n2j.js} +127 -51
- package/dist/vendor/{cli-api.DTeni0Qq.js → cli-api.C8t8m4__.js} +2771 -1711
- package/dist/vendor/{constants.5SOfHUj0.js → constants.BWsVtsAj.js} +6 -22
- package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
- package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
- package/dist/vendor/{execute.CLLNVNnK.js → execute.T3gg2ZK6.js} +177 -63
- package/dist/vendor/{index.BfoZyXD1.js → index.-dbR4KUi.js} +17 -9
- package/dist/vendor/{index.CRxYS9H3.js → index.BC5zhX9y.js} +1201 -491
- package/dist/vendor/{index.DP-km6lF.js → index.BMmMjLIQ.js} +64 -51
- package/dist/vendor/{index._7XLd8Kd.js → index.C9Thslzw.js} +2 -1
- package/dist/vendor/{index.CmILuxzC.js → index.CQJ2m700.js} +3 -3
- package/dist/vendor/{index.DeR1hhfY.js → index.D4nqnQWz.js} +71 -74
- package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
- package/dist/vendor/{run-once.DLomgGUH.js → run-once.Db8Hgq9X.js} +2 -1
- package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.uqZOEWuR.js} +30 -15
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.D5gGkwyH.js → utils.DSO2UK15.js} +41 -26
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.ClD3hi7L.js → vi.BPjl8cAZ.js} +350 -166
- package/dist/vendor/{vm.Bi3bljci.js → vm.CycSoHnJ.js} +151 -86
- package/dist/worker.js +31 -15
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +14 -13
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +9 -9
- package/package.json +22 -22
- package/suppress-warnings.cjs +2 -4
package/dist/config.js
CHANGED
|
@@ -6,9 +6,25 @@ var _a$1;
|
|
|
6
6
|
const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a$1 = process.versions) == null ? void 0 : _a$1.deno) && !globalThis.window;
|
|
7
7
|
isNode && process.platform === "win32";
|
|
8
8
|
|
|
9
|
+
const defaultBrowserPort = 63315;
|
|
10
|
+
const extraInlineDeps = [
|
|
11
|
+
/^(?!.*node_modules).*\.mjs$/,
|
|
12
|
+
/^(?!.*node_modules).*\.cjs\.js$/,
|
|
13
|
+
// Vite client
|
|
14
|
+
/vite\w*\/dist\/client\/env.mjs/,
|
|
15
|
+
// Nuxt
|
|
16
|
+
"@nuxt/test-utils"
|
|
17
|
+
];
|
|
18
|
+
|
|
9
19
|
var _a, _b;
|
|
10
20
|
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
11
|
-
const defaultExclude = [
|
|
21
|
+
const defaultExclude = [
|
|
22
|
+
"**/node_modules/**",
|
|
23
|
+
"**/dist/**",
|
|
24
|
+
"**/cypress/**",
|
|
25
|
+
"**/.{idea,git,cache,output,temp}/**",
|
|
26
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
|
|
27
|
+
];
|
|
12
28
|
const defaultCoverageExcludes = [
|
|
13
29
|
"coverage/**",
|
|
14
30
|
"dist/**",
|
|
@@ -36,11 +52,31 @@ const coverageConfigDefaults = {
|
|
|
36
52
|
reportsDirectory: "./coverage",
|
|
37
53
|
exclude: defaultCoverageExcludes,
|
|
38
54
|
reportOnFailure: false,
|
|
39
|
-
reporter: [
|
|
40
|
-
|
|
55
|
+
reporter: [
|
|
56
|
+
["text", {}],
|
|
57
|
+
["html", {}],
|
|
58
|
+
["clover", {}],
|
|
59
|
+
["json", {}]
|
|
60
|
+
],
|
|
61
|
+
extension: [
|
|
62
|
+
".js",
|
|
63
|
+
".cjs",
|
|
64
|
+
".mjs",
|
|
65
|
+
".ts",
|
|
66
|
+
".mts",
|
|
67
|
+
".cts",
|
|
68
|
+
".tsx",
|
|
69
|
+
".jsx",
|
|
70
|
+
".vue",
|
|
71
|
+
".svelte",
|
|
72
|
+
".marko"
|
|
73
|
+
],
|
|
41
74
|
allowExternal: false,
|
|
42
75
|
ignoreEmptyLines: true,
|
|
43
|
-
processingConcurrency: Math.min(
|
|
76
|
+
processingConcurrency: Math.min(
|
|
77
|
+
20,
|
|
78
|
+
((_b = (_a = os).availableParallelism) == null ? void 0 : _b.call(_a)) ?? os.cpus().length
|
|
79
|
+
)
|
|
44
80
|
};
|
|
45
81
|
const fakeTimersDefaults = {
|
|
46
82
|
loopLimit: 1e4,
|
|
@@ -61,19 +97,14 @@ const config = {
|
|
|
61
97
|
watch: !isCI,
|
|
62
98
|
globals: false,
|
|
63
99
|
environment: "node",
|
|
64
|
-
pool: "
|
|
100
|
+
pool: "forks",
|
|
65
101
|
clearMocks: false,
|
|
66
102
|
restoreMocks: false,
|
|
67
103
|
mockReset: false,
|
|
68
104
|
include: defaultInclude,
|
|
69
105
|
exclude: defaultExclude,
|
|
70
|
-
testTimeout: 5e3,
|
|
71
|
-
hookTimeout: 1e4,
|
|
72
106
|
teardownTimeout: 1e4,
|
|
73
|
-
forceRerunTriggers: [
|
|
74
|
-
"**/package.json/**",
|
|
75
|
-
"**/{vitest,vite}.config.*/**"
|
|
76
|
-
],
|
|
107
|
+
forceRerunTriggers: ["**/package.json/**", "**/{vitest,vite}.config.*/**"],
|
|
77
108
|
update: false,
|
|
78
109
|
reporters: [],
|
|
79
110
|
silent: false,
|
|
@@ -99,15 +130,6 @@ const config = {
|
|
|
99
130
|
};
|
|
100
131
|
const configDefaults = Object.freeze(config);
|
|
101
132
|
|
|
102
|
-
const extraInlineDeps = [
|
|
103
|
-
/^(?!.*(?:node_modules)).*\.mjs$/,
|
|
104
|
-
/^(?!.*(?:node_modules)).*\.cjs\.js$/,
|
|
105
|
-
// Vite client
|
|
106
|
-
/vite\w*\/dist\/client\/env.mjs/,
|
|
107
|
-
// Nuxt
|
|
108
|
-
"@nuxt/test-utils"
|
|
109
|
-
];
|
|
110
|
-
|
|
111
133
|
function defineConfig(config) {
|
|
112
134
|
return config;
|
|
113
135
|
}
|
|
@@ -118,4 +140,4 @@ function defineWorkspace(config) {
|
|
|
118
140
|
return config;
|
|
119
141
|
}
|
|
120
142
|
|
|
121
|
-
export { configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace, extraInlineDeps };
|
|
143
|
+
export { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace, extraInlineDeps };
|
package/dist/coverage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-
|
|
1
|
+
import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-fiIq_dT9.js';
|
|
2
2
|
import 'vite';
|
|
3
3
|
import '@vitest/runner';
|
|
4
4
|
import 'vite-node';
|
|
@@ -129,7 +129,7 @@ declare class BaseCoverageProvider {
|
|
|
129
129
|
/**
|
|
130
130
|
* Check if current coverage is above configured thresholds and bump the thresholds if needed
|
|
131
131
|
*/
|
|
132
|
-
updateThresholds({ thresholds: allThresholds, perFile, configurationFile, onUpdate }: {
|
|
132
|
+
updateThresholds({ thresholds: allThresholds, perFile, configurationFile, onUpdate, }: {
|
|
133
133
|
thresholds: ResolvedThreshold[];
|
|
134
134
|
perFile?: boolean;
|
|
135
135
|
configurationFile: unknown;
|
|
@@ -138,7 +138,7 @@ declare class BaseCoverageProvider {
|
|
|
138
138
|
/**
|
|
139
139
|
* Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
|
|
140
140
|
*/
|
|
141
|
-
checkThresholds({ thresholds: allThresholds, perFile }: {
|
|
141
|
+
checkThresholds({ thresholds: allThresholds, perFile, }: {
|
|
142
142
|
thresholds: ResolvedThreshold[];
|
|
143
143
|
perFile?: boolean;
|
|
144
144
|
}): void;
|
|
@@ -147,7 +147,7 @@ declare class BaseCoverageProvider {
|
|
|
147
147
|
* where each threshold set holds their own coverage maps. Threshold set is either
|
|
148
148
|
* for specific files defined by glob pattern or global for all other files.
|
|
149
149
|
*/
|
|
150
|
-
resolveThresholds({ coverageMap, thresholds, createCoverageMap, root }: {
|
|
150
|
+
resolveThresholds({ coverageMap, thresholds, createCoverageMap, root, }: {
|
|
151
151
|
coverageMap: CoverageMap;
|
|
152
152
|
thresholds: NonNullable<BaseCoverageOptions['thresholds']>;
|
|
153
153
|
createCoverageMap: () => CoverageMap;
|
package/dist/coverage.js
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
import { relative } from 'pathe';
|
|
2
|
-
import { m as mm } from './vendor/index.
|
|
2
|
+
import { m as mm } from './vendor/index.BMmMjLIQ.js';
|
|
3
3
|
import './vendor/_commonjsHelpers.BFTU3MAI.js';
|
|
4
4
|
import 'util';
|
|
5
5
|
import 'path';
|
|
6
6
|
|
|
7
|
-
const THRESHOLD_KEYS = [
|
|
7
|
+
const THRESHOLD_KEYS = [
|
|
8
|
+
"lines",
|
|
9
|
+
"functions",
|
|
10
|
+
"statements",
|
|
11
|
+
"branches"
|
|
12
|
+
];
|
|
8
13
|
const GLOBAL_THRESHOLDS_KEY = "global";
|
|
9
14
|
class BaseCoverageProvider {
|
|
10
15
|
/**
|
|
11
16
|
* Check if current coverage is above configured thresholds and bump the thresholds if needed
|
|
12
17
|
*/
|
|
13
|
-
updateThresholds({
|
|
18
|
+
updateThresholds({
|
|
19
|
+
thresholds: allThresholds,
|
|
20
|
+
perFile,
|
|
21
|
+
configurationFile,
|
|
22
|
+
onUpdate
|
|
23
|
+
}) {
|
|
14
24
|
let updatedThresholds = false;
|
|
15
25
|
const config = resolveConfig(configurationFile);
|
|
16
26
|
assertConfigurationModule(config);
|
|
17
27
|
for (const { coverageMap, thresholds, name } of allThresholds) {
|
|
18
|
-
const summaries = perFile ? coverageMap.files().map(
|
|
28
|
+
const summaries = perFile ? coverageMap.files().map(
|
|
29
|
+
(file) => coverageMap.fileCoverageFor(file).toSummary()
|
|
30
|
+
) : [coverageMap.getCoverageSummary()];
|
|
19
31
|
const thresholdsToUpdate = [];
|
|
20
32
|
for (const key of THRESHOLD_KEYS) {
|
|
21
33
|
const threshold = thresholds[key] ?? 100;
|
|
22
|
-
const actual = Math.min(
|
|
23
|
-
|
|
34
|
+
const actual = Math.min(
|
|
35
|
+
...summaries.map((summary) => summary[key].pct)
|
|
36
|
+
);
|
|
37
|
+
if (actual > threshold) {
|
|
24
38
|
thresholdsToUpdate.push([key, actual]);
|
|
39
|
+
}
|
|
25
40
|
}
|
|
26
|
-
if (thresholdsToUpdate.length === 0)
|
|
41
|
+
if (thresholdsToUpdate.length === 0) {
|
|
27
42
|
continue;
|
|
43
|
+
}
|
|
28
44
|
updatedThresholds = true;
|
|
29
45
|
for (const [threshold, newValue] of thresholdsToUpdate) {
|
|
30
46
|
if (name === GLOBAL_THRESHOLDS_KEY) {
|
|
@@ -36,34 +52,51 @@ class BaseCoverageProvider {
|
|
|
36
52
|
}
|
|
37
53
|
}
|
|
38
54
|
if (updatedThresholds) {
|
|
39
|
-
console.log(
|
|
55
|
+
console.log(
|
|
56
|
+
"Updating thresholds to configuration file. You may want to push with updated coverage thresholds."
|
|
57
|
+
);
|
|
40
58
|
onUpdate();
|
|
41
59
|
}
|
|
42
60
|
}
|
|
43
61
|
/**
|
|
44
62
|
* Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
|
|
45
63
|
*/
|
|
46
|
-
checkThresholds({
|
|
64
|
+
checkThresholds({
|
|
65
|
+
thresholds: allThresholds,
|
|
66
|
+
perFile
|
|
67
|
+
}) {
|
|
47
68
|
for (const { coverageMap, thresholds, name } of allThresholds) {
|
|
48
|
-
if (thresholds.branches === void 0 && thresholds.functions === void 0 && thresholds.lines === void 0 && thresholds.statements === void 0)
|
|
69
|
+
if (thresholds.branches === void 0 && thresholds.functions === void 0 && thresholds.lines === void 0 && thresholds.statements === void 0) {
|
|
49
70
|
continue;
|
|
71
|
+
}
|
|
50
72
|
const summaries = perFile ? coverageMap.files().map((file) => ({
|
|
51
73
|
file,
|
|
52
74
|
summary: coverageMap.fileCoverageFor(file).toSummary()
|
|
53
|
-
})) : [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
})) : [
|
|
76
|
+
{
|
|
77
|
+
file: null,
|
|
78
|
+
summary: coverageMap.getCoverageSummary()
|
|
79
|
+
}
|
|
80
|
+
];
|
|
57
81
|
for (const { summary, file } of summaries) {
|
|
58
|
-
for (const thresholdKey of [
|
|
82
|
+
for (const thresholdKey of [
|
|
83
|
+
"lines",
|
|
84
|
+
"functions",
|
|
85
|
+
"statements",
|
|
86
|
+
"branches"
|
|
87
|
+
]) {
|
|
59
88
|
const threshold = thresholds[thresholdKey];
|
|
60
89
|
if (threshold !== void 0) {
|
|
61
90
|
const coverage = summary.data[thresholdKey].pct;
|
|
62
91
|
if (coverage < threshold) {
|
|
63
92
|
process.exitCode = 1;
|
|
64
93
|
let errorMessage = `ERROR: Coverage for ${thresholdKey} (${coverage}%) does not meet ${name === GLOBAL_THRESHOLDS_KEY ? name : `"${name}"`} threshold (${threshold}%)`;
|
|
65
|
-
if (perFile && file)
|
|
66
|
-
errorMessage += ` for ${relative("./", file).replace(
|
|
94
|
+
if (perFile && file) {
|
|
95
|
+
errorMessage += ` for ${relative("./", file).replace(
|
|
96
|
+
/\\/g,
|
|
97
|
+
"/"
|
|
98
|
+
)}`;
|
|
99
|
+
}
|
|
67
100
|
console.error(errorMessage);
|
|
68
101
|
}
|
|
69
102
|
}
|
|
@@ -76,18 +109,28 @@ class BaseCoverageProvider {
|
|
|
76
109
|
* where each threshold set holds their own coverage maps. Threshold set is either
|
|
77
110
|
* for specific files defined by glob pattern or global for all other files.
|
|
78
111
|
*/
|
|
79
|
-
resolveThresholds({
|
|
112
|
+
resolveThresholds({
|
|
113
|
+
coverageMap,
|
|
114
|
+
thresholds,
|
|
115
|
+
createCoverageMap,
|
|
116
|
+
root
|
|
117
|
+
}) {
|
|
80
118
|
const resolvedThresholds = [];
|
|
81
119
|
const files = coverageMap.files();
|
|
82
120
|
const filesMatchedByGlobs = [];
|
|
83
121
|
const globalCoverageMap = createCoverageMap();
|
|
84
|
-
for (const key of Object.keys(
|
|
85
|
-
|
|
122
|
+
for (const key of Object.keys(
|
|
123
|
+
thresholds
|
|
124
|
+
)) {
|
|
125
|
+
if (key === "perFile" || key === "autoUpdate" || key === "100" || THRESHOLD_KEYS.includes(key)) {
|
|
86
126
|
continue;
|
|
127
|
+
}
|
|
87
128
|
const glob = key;
|
|
88
129
|
const globThresholds = resolveGlobThresholds(thresholds[glob]);
|
|
89
130
|
const globCoverageMap = createCoverageMap();
|
|
90
|
-
const matchingFiles = files.filter(
|
|
131
|
+
const matchingFiles = files.filter(
|
|
132
|
+
(file) => mm.isMatch(relative(root, file), glob)
|
|
133
|
+
);
|
|
91
134
|
filesMatchedByGlobs.push(...matchingFiles);
|
|
92
135
|
for (const file of matchingFiles) {
|
|
93
136
|
const fileCoverage = coverageMap.fileCoverageFor(file);
|
|
@@ -99,7 +142,9 @@ class BaseCoverageProvider {
|
|
|
99
142
|
thresholds: globThresholds
|
|
100
143
|
});
|
|
101
144
|
}
|
|
102
|
-
for (const file of files.filter(
|
|
145
|
+
for (const file of files.filter(
|
|
146
|
+
(file2) => !filesMatchedByGlobs.includes(file2)
|
|
147
|
+
)) {
|
|
103
148
|
const fileCoverage = coverageMap.fileCoverageFor(file);
|
|
104
149
|
globalCoverageMap.addFileCoverage(fileCoverage);
|
|
105
150
|
}
|
|
@@ -119,8 +164,9 @@ class BaseCoverageProvider {
|
|
|
119
164
|
* Resolve reporters from various configuration options
|
|
120
165
|
*/
|
|
121
166
|
resolveReporters(configReporters) {
|
|
122
|
-
if (!Array.isArray(configReporters))
|
|
167
|
+
if (!Array.isArray(configReporters)) {
|
|
123
168
|
return [[configReporters, {}]];
|
|
169
|
+
}
|
|
124
170
|
const resolvedReporters = [];
|
|
125
171
|
for (const reporter of configReporters) {
|
|
126
172
|
if (Array.isArray(reporter)) {
|
|
@@ -132,24 +178,28 @@ class BaseCoverageProvider {
|
|
|
132
178
|
return resolvedReporters;
|
|
133
179
|
}
|
|
134
180
|
hasTerminalReporter(reporters) {
|
|
135
|
-
return reporters.some(
|
|
181
|
+
return reporters.some(
|
|
182
|
+
([reporter]) => reporter === "text" || reporter === "text-summary" || reporter === "text-lcov" || reporter === "teamcity"
|
|
183
|
+
);
|
|
136
184
|
}
|
|
137
185
|
toSlices(array, size) {
|
|
138
186
|
return array.reduce((chunks, item) => {
|
|
139
187
|
const index = Math.max(0, chunks.length - 1);
|
|
140
188
|
const lastChunk = chunks[index] || [];
|
|
141
189
|
chunks[index] = lastChunk;
|
|
142
|
-
if (lastChunk.length >= size)
|
|
190
|
+
if (lastChunk.length >= size) {
|
|
143
191
|
chunks.push([item]);
|
|
144
|
-
else
|
|
192
|
+
} else {
|
|
145
193
|
lastChunk.push(item);
|
|
194
|
+
}
|
|
146
195
|
return chunks;
|
|
147
196
|
}, []);
|
|
148
197
|
}
|
|
149
198
|
}
|
|
150
199
|
function resolveGlobThresholds(thresholds) {
|
|
151
|
-
if (!thresholds || typeof thresholds !== "object")
|
|
200
|
+
if (!thresholds || typeof thresholds !== "object") {
|
|
152
201
|
return {};
|
|
202
|
+
}
|
|
153
203
|
return {
|
|
154
204
|
lines: "lines" in thresholds && typeof thresholds.lines === "number" ? thresholds.lines : void 0,
|
|
155
205
|
branches: "branches" in thresholds && typeof thresholds.branches === "number" ? thresholds.branches : void 0,
|
|
@@ -159,28 +209,66 @@ function resolveGlobThresholds(thresholds) {
|
|
|
159
209
|
}
|
|
160
210
|
function assertConfigurationModule(config) {
|
|
161
211
|
try {
|
|
162
|
-
if (typeof config.test.coverage.thresholds !== "object")
|
|
163
|
-
throw new
|
|
212
|
+
if (typeof config.test.coverage.thresholds !== "object") {
|
|
213
|
+
throw new TypeError(
|
|
214
|
+
"Expected config.test.coverage.thresholds to be an object"
|
|
215
|
+
);
|
|
216
|
+
}
|
|
164
217
|
} catch (error) {
|
|
165
218
|
const message = error instanceof Error ? error.message : String(error);
|
|
166
|
-
throw new Error(
|
|
219
|
+
throw new Error(
|
|
220
|
+
`Unable to parse thresholds from configuration file: ${message}`
|
|
221
|
+
);
|
|
167
222
|
}
|
|
168
223
|
}
|
|
169
224
|
function resolveConfig(configModule) {
|
|
170
225
|
const mod = configModule.exports.default;
|
|
171
226
|
try {
|
|
172
|
-
if (mod.$type === "object")
|
|
227
|
+
if (mod.$type === "object") {
|
|
173
228
|
return mod;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
229
|
+
}
|
|
230
|
+
let config = resolveDefineConfig(mod);
|
|
231
|
+
if (config) {
|
|
232
|
+
return config;
|
|
233
|
+
}
|
|
234
|
+
if (mod.$type === "function-call" && mod.$callee === "mergeConfig") {
|
|
235
|
+
config = resolveMergeConfig(mod);
|
|
236
|
+
if (config) {
|
|
237
|
+
return config;
|
|
238
|
+
}
|
|
179
239
|
}
|
|
180
240
|
} catch (error) {
|
|
181
241
|
throw new Error(error instanceof Error ? error.message : String(error));
|
|
182
242
|
}
|
|
183
|
-
throw new Error(
|
|
243
|
+
throw new Error(
|
|
244
|
+
"Failed to update coverage thresholds. Configuration file is too complex."
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function resolveDefineConfig(mod) {
|
|
248
|
+
if (mod.$type === "function-call" && mod.$callee === "defineConfig") {
|
|
249
|
+
if (mod.$args[0].$type === "object") {
|
|
250
|
+
return mod.$args[0];
|
|
251
|
+
}
|
|
252
|
+
if (mod.$args[0].$type === "arrow-function-expression") {
|
|
253
|
+
if (mod.$args[0].$body.$type === "object") {
|
|
254
|
+
return mod.$args[0].$body;
|
|
255
|
+
}
|
|
256
|
+
const config = resolveMergeConfig(mod.$args[0].$body);
|
|
257
|
+
if (config) {
|
|
258
|
+
return config;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function resolveMergeConfig(mod) {
|
|
264
|
+
if (mod.$type === "function-call" && mod.$callee === "mergeConfig") {
|
|
265
|
+
for (const arg of mod.$args) {
|
|
266
|
+
const config = resolveDefineConfig(arg);
|
|
267
|
+
if (config) {
|
|
268
|
+
return config;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
184
272
|
}
|
|
185
273
|
|
|
186
274
|
export { BaseCoverageProvider };
|
package/dist/environments.d.ts
CHANGED
package/dist/environments.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.
|
|
1
|
+
export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.D4nqnQWz.js';
|
|
2
2
|
import 'node:console';
|
package/dist/execute.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import vm from 'node:vm';
|
|
2
2
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
3
3
|
import { ViteNodeRunnerOptions } from 'vite-node';
|
|
4
|
-
import {
|
|
4
|
+
import { aG as PendingSuiteMock, aH as MockFactory, e as RuntimeRPC, W as WorkerGlobalState, aI as MockMap } from './reporters-fiIq_dT9.js';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import '@vitest/runner';
|
|
7
7
|
import '@vitest/snapshot';
|
|
@@ -38,7 +38,7 @@ declare class VitestMocker {
|
|
|
38
38
|
private get moduleDirectories();
|
|
39
39
|
initializeSpyModule(): Promise<void>;
|
|
40
40
|
private deleteCachedItem;
|
|
41
|
-
private
|
|
41
|
+
private isModuleDirectory;
|
|
42
42
|
getSuiteFilepath(): string;
|
|
43
43
|
private createError;
|
|
44
44
|
getMocks(): {
|
package/dist/execute.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { V as VitestExecutor } from './vendor/execute.
|
|
1
|
+
export { V as VitestExecutor } from './vendor/execute.T3gg2ZK6.js';
|
|
2
2
|
import 'node:vm';
|
|
3
3
|
import 'node:url';
|
|
4
4
|
import 'node:fs';
|
|
@@ -8,4 +8,4 @@ import 'pathe';
|
|
|
8
8
|
import '@vitest/utils/error';
|
|
9
9
|
import './path.js';
|
|
10
10
|
import '@vitest/utils';
|
|
11
|
-
import './vendor/base.
|
|
11
|
+
import './vendor/base.CTYV4Gnz.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { TaskPopulated, File, TaskResultPack
|
|
2
|
-
export { Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
3
|
-
export { b as bench } from './suite-
|
|
1
|
+
import { TaskPopulated, File, TaskResultPack } from '@vitest/runner';
|
|
2
|
+
export { CancelReason, Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
3
|
+
export { b as bench } from './suite-D4aoU9rI.js';
|
|
4
4
|
import { ExpectStatic } from '@vitest/expect';
|
|
5
5
|
export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
|
|
6
|
-
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper,
|
|
7
|
-
export {
|
|
6
|
+
import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, h as RuntimeConfig, P as ProvidedContext, R as ResolvedConfig, i as ModuleGraphData, j as Reporter, k as BirpcReturn } from './reporters-fiIq_dT9.js';
|
|
7
|
+
export { Y as AfterSuiteRunMeta, A as ApiConfig, a1 as ArgumentsType, a0 as Arrayable, _ as Awaitable, B as BaseCoverageOptions, ah as BenchFunction, af as Benchmark, ai as BenchmarkAPI, ag as BenchmarkResult, ae as BenchmarkUserOptions, G as BrowserConfigOptions, z as BrowserScript, s as BuiltinEnvironment, t as CSSModuleScopeStrategy, m as CollectLineNumbers, n as CollectLines, a3 as Constructable, p as Context, f as ContextRPC, N as ContextTestEnvironment, ab as CoverageIstanbulOptions, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule, aa as CoverageReporter, ac as CoverageV8Options, ad as CustomProviderOptions, D as DepsOptimizationOptions, E as Environment, u as EnvironmentOptions, a5 as EnvironmentReturn, H as HappyDOMOptions, I as InlineConfig, J as JSDOMOptions, a4 as ModuleCache, a2 as MutableArray, $ as Nullable, a8 as OnServerRestartHandler, q as Pool, r as PoolOptions, y as ProjectConfig, l as RawErrsMap, a9 as ReportContext, X as ResolveIdFunction, a as ResolvedCoverageOptions, O as ResolvedTestEnvironment, o as RootAndTarget, L as RunnerRPC, e as RuntimeRPC, S as SerializableSpec, w as TransformModePatterns, T as TscErrorInfo, x as TypecheckConfig, U as UserConfig, a7 as UserConsoleLog, K as UserWorkspaceConfig, Q as Vitest, V as VitestEnvironment, v as VitestRunMode, a6 as VmEnvironmentReturn, g as WorkerContext, W as WorkerGlobalState, Z as WorkerRPC } from './reporters-fiIq_dT9.js';
|
|
8
8
|
import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
|
|
9
9
|
export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
|
|
10
|
-
export { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
11
|
-
import { SnapshotResult } from '@vitest/snapshot';
|
|
12
10
|
export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
|
|
13
11
|
export { DiffOptions } from '@vitest/utils/diff';
|
|
14
12
|
import { TransformResult } from 'vite';
|
|
@@ -1056,6 +1054,11 @@ interface AssertType {
|
|
|
1056
1054
|
}
|
|
1057
1055
|
declare const assertType: AssertType;
|
|
1058
1056
|
|
|
1057
|
+
interface BrowserUI {
|
|
1058
|
+
setCurrentFileId: (fileId: string) => void;
|
|
1059
|
+
setIframeViewport: (width: number, height: number) => Promise<void>;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1059
1062
|
/**
|
|
1060
1063
|
* This utils allows computational intensive tasks to only be ran once
|
|
1061
1064
|
* across test reruns to improve the watch mode performance.
|
|
@@ -1064,7 +1067,7 @@ declare const assertType: AssertType;
|
|
|
1064
1067
|
*
|
|
1065
1068
|
* @experimental
|
|
1066
1069
|
*/
|
|
1067
|
-
declare function runOnce<T>(fn: (
|
|
1070
|
+
declare function runOnce<T>(fn: () => T, key?: string): T;
|
|
1068
1071
|
/**
|
|
1069
1072
|
* Get a boolean indicates whether the task is running in the first time.
|
|
1070
1073
|
* Could only be `false` in watch mode.
|
|
@@ -1423,39 +1426,26 @@ interface TransformResultWithSource extends TransformResult {
|
|
|
1423
1426
|
source?: string;
|
|
1424
1427
|
}
|
|
1425
1428
|
interface WebSocketHandlers {
|
|
1426
|
-
onUnhandledError: (error: unknown, type: string) => Promise<void>;
|
|
1427
1429
|
onCollected: (files?: File[]) => Promise<void>;
|
|
1428
1430
|
onTaskUpdate: (packs: TaskResultPack[]) => void;
|
|
1429
|
-
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
1430
|
-
onCancel: (reason: CancelReason) => void;
|
|
1431
|
-
getCountOfFailedTests: () => number;
|
|
1432
|
-
sendLog: (log: UserConsoleLog) => void;
|
|
1433
1431
|
getFiles: () => File[];
|
|
1434
|
-
getTestFiles: () => Promise<[
|
|
1432
|
+
getTestFiles: () => Promise<[{
|
|
1433
|
+
name: string;
|
|
1434
|
+
root: string;
|
|
1435
|
+
}, file: string][]>;
|
|
1435
1436
|
getPaths: () => string[];
|
|
1436
1437
|
getConfig: () => ResolvedConfig;
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
getModuleGraph: (id: string) => Promise<ModuleGraphData>;
|
|
1440
|
-
getBrowserFileSourceMap: (id: string) => Promise<TransformResult['map'] | undefined>;
|
|
1441
|
-
getTransformResult: (id: string) => Promise<TransformResultWithSource | undefined>;
|
|
1442
|
-
readSnapshotFile: (id: string) => Promise<string | null>;
|
|
1438
|
+
getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
|
|
1439
|
+
getTransformResult: (projectName: string, id: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
|
|
1443
1440
|
readTestFile: (id: string) => Promise<string | null>;
|
|
1444
1441
|
saveTestFile: (id: string, content: string) => Promise<void>;
|
|
1445
|
-
saveSnapshotFile: (id: string, content: string) => Promise<void>;
|
|
1446
|
-
removeSnapshotFile: (id: string) => Promise<void>;
|
|
1447
|
-
snapshotSaved: (snapshot: SnapshotResult) => void;
|
|
1448
1442
|
rerun: (files: string[]) => Promise<void>;
|
|
1449
1443
|
updateSnapshot: (file?: File) => Promise<void>;
|
|
1450
|
-
getProvidedContext: () => ProvidedContext;
|
|
1451
1444
|
getUnhandledErrors: () => unknown[];
|
|
1452
|
-
finishBrowserTests: () => void;
|
|
1453
|
-
getBrowserFiles: () => string[];
|
|
1454
|
-
debug: (...args: string[]) => void;
|
|
1455
1445
|
}
|
|
1456
|
-
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected'> {
|
|
1457
|
-
onCancel: (reason: CancelReason) => void;
|
|
1446
|
+
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected' | 'onSpecsCollected'> {
|
|
1458
1447
|
onFinishedReportCoverage: () => void;
|
|
1459
1448
|
}
|
|
1449
|
+
type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
|
|
1460
1450
|
|
|
1461
|
-
export {
|
|
1451
|
+
export { type AssertType, type BrowserUI, type ExpectTypeOf, ModuleGraphData, ProvidedContext, Reporter, ResolvedConfig, RuntimeConfig, type TransformResultWithSource, type VitestUtils, type WebSocketEvents, type WebSocketHandlers, type WebSocketRPC, assertType, createExpect, globalExpect as expect, expectTypeOf, getRunningMode, inject, isFirstRun, isWatchMode, runOnce, vi, vitest };
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
|
-
export { b as bench } from './vendor/benchmark.
|
|
3
|
-
export { i as isFirstRun, a as runOnce } from './vendor/run-once.
|
|
4
|
-
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.
|
|
5
|
-
import { d as dist } from './vendor/index.
|
|
6
|
-
export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.
|
|
2
|
+
export { b as bench } from './vendor/benchmark.CMp8QfyL.js';
|
|
3
|
+
export { i as isFirstRun, a as runOnce } from './vendor/run-once.Db8Hgq9X.js';
|
|
4
|
+
export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.BPjl8cAZ.js';
|
|
5
|
+
import { d as dist } from './vendor/index.CQJ2m700.js';
|
|
6
|
+
export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.CQJ2m700.js';
|
|
7
7
|
import * as chai from 'chai';
|
|
8
8
|
export { chai };
|
|
9
9
|
export { assert, should } from 'chai';
|
|
10
10
|
import '@vitest/runner/utils';
|
|
11
11
|
import '@vitest/utils';
|
|
12
|
-
import './vendor/index.
|
|
12
|
+
import './vendor/index.C9Thslzw.js';
|
|
13
13
|
import 'pathe';
|
|
14
14
|
import './vendor/global.7bFbnyXl.js';
|
|
15
15
|
import './vendor/env.bmJgw1qP.js';
|
|
@@ -18,10 +18,10 @@ import './vendor/_commonjsHelpers.BFTU3MAI.js';
|
|
|
18
18
|
import '@vitest/expect';
|
|
19
19
|
import '@vitest/snapshot';
|
|
20
20
|
import '@vitest/utils/error';
|
|
21
|
-
import './vendor/tasks.
|
|
21
|
+
import './vendor/tasks.DhVtQBtW.js';
|
|
22
22
|
import '@vitest/utils/source-map';
|
|
23
|
-
import './vendor/base.
|
|
24
|
-
import './vendor/date.
|
|
23
|
+
import './vendor/base.CTYV4Gnz.js';
|
|
24
|
+
import './vendor/date.W2xKR2qe.js';
|
|
25
25
|
import '@vitest/spy';
|
|
26
26
|
|
|
27
27
|
|
package/dist/node.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { UserConfig as UserConfig$1, Plugin } from 'vite';
|
|
1
|
+
import { v as VitestRunMode, U as UserConfig, aj as VitestOptions, Q as Vitest, R as ResolvedConfig, P as ProvidedContext, ak as WorkspaceProject, e as RuntimeRPC, A as ApiConfig, al as Logger, am as TestSequencer, an as WorkspaceSpec } from './reporters-fiIq_dT9.js';
|
|
2
|
+
export { ax as BrowserCommand, ay as BrowserCommandContext, aC as BrowserOrchestrator, at as BrowserProvider, as as BrowserProviderInitializationOptions, au as BrowserProviderModule, aw as BrowserProviderOptions, z as BrowserScript, az as BrowserServer, aA as BrowserServerState, aB as BrowserServerStateContext, aF as HTMLOptions, aE as JUnitOptions, aD as JsonOptions, ao as ProcessPool, av as ResolvedBrowserOptions, ar as TestSequencerConstructor, aq as VitestPackageInstaller, ap as getFilePoolName } from './reporters-fiIq_dT9.js';
|
|
3
|
+
import { UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1 } from 'vite';
|
|
4
|
+
import * as vite from 'vite';
|
|
5
|
+
export { vite as Vite };
|
|
6
|
+
export { createServer, isFileServingAllowed } from 'vite';
|
|
4
7
|
import { Writable } from 'node:stream';
|
|
8
|
+
import createDebug from 'debug';
|
|
5
9
|
import '@vitest/runner';
|
|
6
10
|
import 'vite-node';
|
|
7
11
|
import '@vitest/snapshot';
|
|
@@ -25,10 +29,6 @@ interface CliOptions extends UserConfig {
|
|
|
25
29
|
* Override the watch mode
|
|
26
30
|
*/
|
|
27
31
|
run?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Retry the test suite if it crashes due to a segfault (default: true)
|
|
30
|
-
*/
|
|
31
|
-
segfaultRetry?: number;
|
|
32
32
|
/**
|
|
33
33
|
* Removes colors from the console output
|
|
34
34
|
*/
|
|
@@ -56,7 +56,20 @@ interface GlobalSetupContext {
|
|
|
56
56
|
provide: <T extends keyof ProvidedContext>(key: T, value: ProvidedContext[T]) => void;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
interface MethodsOptions {
|
|
60
|
+
cacheFs?: boolean;
|
|
61
|
+
}
|
|
62
|
+
declare function createMethodsRPC(project: WorkspaceProject, options?: MethodsOptions): RuntimeRPC;
|
|
63
|
+
|
|
64
|
+
declare function createDebugger(namespace: `vitest:${string}`): createDebug.Debugger | undefined;
|
|
65
|
+
|
|
66
|
+
declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | false | undefined): string[];
|
|
67
|
+
|
|
68
|
+
declare function resolveApiServerConfig<Options extends ApiConfig & UserConfig>(options: Options, defaultPort: number): ApiConfig | undefined;
|
|
69
|
+
declare function resolveConfig(mode: VitestRunMode, options: UserConfig, viteConfig: ResolvedConfig$1, logger: Logger): ResolvedConfig;
|
|
70
|
+
|
|
71
|
+
declare const rootDir: string;
|
|
72
|
+
declare const distDir: string;
|
|
60
73
|
|
|
61
74
|
declare class BaseSequencer implements TestSequencer {
|
|
62
75
|
protected ctx: Vitest;
|
|
@@ -65,4 +78,4 @@ declare class BaseSequencer implements TestSequencer {
|
|
|
65
78
|
sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
|
|
66
79
|
}
|
|
67
80
|
|
|
68
|
-
export { BaseSequencer, type GlobalSetupContext, TestSequencer, Vitest, VitestPlugin, WorkspaceProject, WorkspaceSpec, createMethodsRPC, createVitest, parseCLI, registerConsoleShortcuts, startVitest };
|
|
81
|
+
export { BaseSequencer, type GlobalSetupContext, TestSequencer, Vitest, VitestPlugin, WorkspaceProject, WorkspaceSpec, createDebugger, createMethodsRPC, createVitest, distDir, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rootDir, startVitest };
|