vitest 0.31.4 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/child.js +4 -3
- package/dist/{chunk-api-setup.3854747a.js → chunk-api-setup.05e3917b.js} +1 -1
- package/dist/{chunk-install-pkg.4f68b0aa.js → chunk-install-pkg.65daeadb.js} +3 -3
- package/dist/{chunk-integrations-globals.6a234998.js → chunk-integrations-globals.a56dee90.js} +3 -2
- package/dist/cli.js +18 -7
- package/dist/config.cjs +8 -9
- package/dist/config.d.ts +5 -3
- package/dist/config.js +8 -9
- package/dist/coverage.d.ts +9 -1
- package/dist/coverage.js +31 -0
- package/dist/entry.js +5 -4
- package/dist/environments.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -3
- package/dist/node.d.ts +9 -6
- package/dist/node.js +5 -4
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +2 -1
- package/dist/{types-dea83b3d.d.ts → types-2b1c412e.d.ts} +30 -10
- package/dist/{vendor-cli-api.8cf937e8.js → vendor-cli-api.17011d0a.js} +177 -159
- package/dist/{vendor-coverage.c8fd34c3.js → vendor-coverage.de2180ed.js} +2 -1
- package/dist/{vendor-execute.132a3e09.js → vendor-execute.001ae440.js} +36 -8
- package/dist/{vendor-index.f81f6285.js → vendor-index.0f133dbe.js} +1 -1
- package/dist/{vendor-index.5037f2c0.js → vendor-index.87ab04c3.js} +2 -2
- package/dist/{vendor-setup.common.823a1300.js → vendor-setup.common.f1cf2231.js} +1 -1
- package/dist/{vendor-vi.23b98fa1.js → vendor-vi.74cf3ef7.js} +34 -4
- package/dist/worker.js +3 -3
- package/package.json +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve as resolve$2, relative, isAbsolute, dirname, basename, normalize, join, extname, toNamespacedPath } from 'pathe';
|
|
2
2
|
import { E as EXIT_CODE_RESTART, c as configFiles, d as defaultPort, a as defaultBrowserPort, w as workspacesFiles, C as CONFIG_NAMES } from './vendor-constants.538d9b49.js';
|
|
3
|
-
import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.
|
|
3
|
+
import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.de2180ed.js';
|
|
4
4
|
import { g as getEnvPackageName } from './vendor-index.75f2b63d.js';
|
|
5
5
|
import url, { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
6
|
import c from 'picocolors';
|
|
@@ -25,7 +25,7 @@ import { ViteNodeServer } from 'vite-node/server';
|
|
|
25
25
|
import { d as distDir, r as rootDir } from './vendor-paths.84fc7a99.js';
|
|
26
26
|
import v8 from 'node:v8';
|
|
27
27
|
import { fork } from 'node:child_process';
|
|
28
|
-
import { g as groupBy, a as getEnvironmentTransformMode, c as createBirpc, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, b as stdout } from './vendor-index.
|
|
28
|
+
import { g as groupBy, a as getEnvironmentTransformMode, c as createBirpc, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, b as stdout } from './vendor-index.87ab04c3.js';
|
|
29
29
|
import { MessageChannel } from 'node:worker_threads';
|
|
30
30
|
import { cpus, hostname } from 'node:os';
|
|
31
31
|
import Tinypool from 'tinypool';
|
|
@@ -60,13 +60,15 @@ function _mergeNamespaces(n, m) {
|
|
|
60
60
|
return Object.freeze(n);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
var version$1 = "0.
|
|
63
|
+
var version$1 = "0.32.1";
|
|
64
64
|
|
|
65
65
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
66
|
-
async function ensurePackageInstalled(dependency, root) {
|
|
66
|
+
async function ensurePackageInstalled(dependency, root, errorMessage) {
|
|
67
67
|
if (isPackageExists(dependency, { paths: [root, __dirname$1] }))
|
|
68
68
|
return true;
|
|
69
69
|
const promptInstall = !isCI && process.stdout.isTTY;
|
|
70
|
+
if (errorMessage)
|
|
71
|
+
process.stderr.write(c.red(errorMessage));
|
|
70
72
|
process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
|
71
73
|
|
|
72
74
|
`));
|
|
@@ -79,7 +81,7 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
79
81
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
80
82
|
});
|
|
81
83
|
if (install) {
|
|
82
|
-
await (await import('./chunk-install-pkg.
|
|
84
|
+
await (await import('./chunk-install-pkg.65daeadb.js')).installPackage(dependency, { dev: true });
|
|
83
85
|
process.stderr.write(c.yellow(`
|
|
84
86
|
Package ${dependency} installed, re-run the command to start.
|
|
85
87
|
`));
|
|
@@ -9503,8 +9505,12 @@ class JUnitReporter {
|
|
|
9503
9505
|
await promises.mkdir(outputDirectory, { recursive: true });
|
|
9504
9506
|
const fileFd = await promises.open(this.reportFile, "w+");
|
|
9505
9507
|
this.fileFd = fileFd;
|
|
9506
|
-
this.baseLog = async (text) =>
|
|
9508
|
+
this.baseLog = async (text) => {
|
|
9509
|
+
if (!this.fileFd)
|
|
9510
|
+
this.fileFd = await promises.open(this.reportFile, "w+");
|
|
9511
|
+
await promises.writeFile(this.fileFd, `${text}
|
|
9507
9512
|
`);
|
|
9513
|
+
};
|
|
9508
9514
|
} else {
|
|
9509
9515
|
this.baseLog = async (text) => this.ctx.logger.log(text);
|
|
9510
9516
|
}
|
|
@@ -9635,6 +9641,7 @@ class JUnitReporter {
|
|
|
9635
9641
|
if (this.reportFile)
|
|
9636
9642
|
this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`);
|
|
9637
9643
|
await ((_a = this.fileFd) == null ? void 0 : _a.close());
|
|
9644
|
+
this.fileFd = void 0;
|
|
9638
9645
|
}
|
|
9639
9646
|
}
|
|
9640
9647
|
|
|
@@ -10144,10 +10151,10 @@ class StateManager {
|
|
|
10144
10151
|
}
|
|
10145
10152
|
}
|
|
10146
10153
|
|
|
10147
|
-
const defaultInclude = ["
|
|
10154
|
+
const defaultInclude = ["**/__tests__/**/*.?(c|m)[jt]s?(x)", "**/?(*.){test,spec}.?(c|m)[jt]s?(x)"];
|
|
10148
10155
|
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
|
|
10149
10156
|
const benchmarkConfigDefaults = {
|
|
10150
|
-
include: ["**/*.{bench,benchmark}
|
|
10157
|
+
include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
|
|
10151
10158
|
exclude: defaultExclude,
|
|
10152
10159
|
includeSource: [],
|
|
10153
10160
|
reporters: ["default"]
|
|
@@ -10155,19 +10162,18 @@ const benchmarkConfigDefaults = {
|
|
|
10155
10162
|
const defaultCoverageExcludes = [
|
|
10156
10163
|
"coverage/**",
|
|
10157
10164
|
"dist/**",
|
|
10158
|
-
"packages/*/test
|
|
10165
|
+
"packages/*/test?(s)/**",
|
|
10159
10166
|
"**/*.d.ts",
|
|
10160
10167
|
"cypress/**",
|
|
10161
|
-
"test
|
|
10162
|
-
"test
|
|
10163
|
-
"**/*{.,-}test
|
|
10164
|
-
"**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
|
|
10168
|
+
"test?(s)/**",
|
|
10169
|
+
"test?(-*).?(c|m)[jt]s?(x)",
|
|
10170
|
+
"**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)",
|
|
10165
10171
|
"**/__tests__/**",
|
|
10166
10172
|
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
|
|
10167
|
-
"**/.{eslint,mocha,prettier}rc.{js,
|
|
10173
|
+
"**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
|
|
10168
10174
|
];
|
|
10169
10175
|
const coverageConfigDefaults = {
|
|
10170
|
-
provider: "
|
|
10176
|
+
provider: "v8",
|
|
10171
10177
|
enabled: false,
|
|
10172
10178
|
clean: true,
|
|
10173
10179
|
cleanOnRerun: true,
|
|
@@ -10229,7 +10235,7 @@ const config = {
|
|
|
10229
10235
|
dangerouslyIgnoreUnhandledErrors: false,
|
|
10230
10236
|
typecheck: {
|
|
10231
10237
|
checker: "tsc",
|
|
10232
|
-
include: ["
|
|
10238
|
+
include: ["**/?(*.){test,spec}-d.?(c|m)[jt]s?(x)"],
|
|
10233
10239
|
exclude: defaultExclude
|
|
10234
10240
|
},
|
|
10235
10241
|
slowTestThreshold: 300
|
|
@@ -10495,6 +10501,8 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10495
10501
|
}
|
|
10496
10502
|
if (resolved.coverage.provider === "c8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
|
|
10497
10503
|
throw new Error("@vitest/coverage-c8 does not work with --browser. Use @vitest/coverage-istanbul instead");
|
|
10504
|
+
if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
|
|
10505
|
+
throw new Error("@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead");
|
|
10498
10506
|
resolved.deps = resolved.deps || {};
|
|
10499
10507
|
if (resolved.deps.inline !== true) {
|
|
10500
10508
|
const ssrOptions = viteConfig.ssr;
|
|
@@ -11165,7 +11173,7 @@ createLogUpdate(process$1.stdout);
|
|
|
11165
11173
|
|
|
11166
11174
|
createLogUpdate(process$1.stderr);
|
|
11167
11175
|
|
|
11168
|
-
var version = "0.
|
|
11176
|
+
var version = "0.32.1";
|
|
11169
11177
|
|
|
11170
11178
|
const comma = ','.charCodeAt(0);
|
|
11171
11179
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -12375,12 +12383,9 @@ As a temporary workaround you can try to inline the package by updating your con
|
|
|
12375
12383
|
` + c.gray(c.dim("// vitest.config.js")) + "\n" + c.green(`export default {
|
|
12376
12384
|
test: {
|
|
12377
12385
|
deps: {
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
${c.yellow(c.bold(`"${name}"`))}
|
|
12382
|
-
]
|
|
12383
|
-
}
|
|
12386
|
+
inline: [
|
|
12387
|
+
${c.yellow(c.bold(`"${name}"`))}
|
|
12388
|
+
]
|
|
12384
12389
|
}
|
|
12385
12390
|
}
|
|
12386
12391
|
}
|
|
@@ -12393,13 +12398,18 @@ function printModuleWarningForSourceCode(logger, path) {
|
|
|
12393
12398
|
));
|
|
12394
12399
|
}
|
|
12395
12400
|
function displayDiff(diff, console) {
|
|
12396
|
-
|
|
12401
|
+
if (diff)
|
|
12402
|
+
console.error(`
|
|
12397
12403
|
${diff}
|
|
12398
12404
|
`);
|
|
12399
12405
|
}
|
|
12400
12406
|
function printErrorMessage(error, logger) {
|
|
12401
12407
|
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
12402
|
-
|
|
12408
|
+
if (error.message.length > 5e3) {
|
|
12409
|
+
logger.error(`${c.red(c.bold(errorName))}: ${error.message}`);
|
|
12410
|
+
} else {
|
|
12411
|
+
logger.error(c.red(`${c.bold(errorName)}: ${error.message}`));
|
|
12412
|
+
}
|
|
12403
12413
|
}
|
|
12404
12414
|
function printStack(ctx, stack, highlight, errorProperties, onStack) {
|
|
12405
12415
|
const logger = ctx.logger;
|
|
@@ -12600,9 +12610,6 @@ function isIdentifier(node) {
|
|
|
12600
12610
|
return node.type === "Identifier";
|
|
12601
12611
|
}
|
|
12602
12612
|
function transformImportSpecifiers(node) {
|
|
12603
|
-
const specifiers = node.specifiers;
|
|
12604
|
-
if (specifiers.length === 1 && specifiers[0].type === "ImportNamespaceSpecifier")
|
|
12605
|
-
return specifiers[0].local.name;
|
|
12606
12613
|
const dynamicImports = node.specifiers.map((specifier) => {
|
|
12607
12614
|
if (specifier.type === "ImportDefaultSpecifier")
|
|
12608
12615
|
return `default: ${specifier.local.name}`;
|
|
@@ -12644,10 +12651,23 @@ ${err.message}`);
|
|
|
12644
12651
|
let hoistedVitestImports = "";
|
|
12645
12652
|
const transformImportDeclaration = (node) => {
|
|
12646
12653
|
const source = node.source.value;
|
|
12654
|
+
const namespace = node.specifiers.find((specifier) => specifier.type === "ImportNamespaceSpecifier");
|
|
12655
|
+
let code2 = "";
|
|
12656
|
+
if (namespace)
|
|
12657
|
+
code2 += `const ${namespace.local.name} = await import('${source}')
|
|
12658
|
+
`;
|
|
12647
12659
|
const specifiers = transformImportSpecifiers(node);
|
|
12648
|
-
|
|
12649
|
-
|
|
12660
|
+
if (specifiers) {
|
|
12661
|
+
if (namespace)
|
|
12662
|
+
code2 += `const ${specifiers} = ${namespace.local.name}
|
|
12663
|
+
`;
|
|
12664
|
+
else
|
|
12665
|
+
code2 += `const ${specifiers} = await import('${source}')
|
|
12666
|
+
`;
|
|
12667
|
+
} else if (!namespace) {
|
|
12668
|
+
code2 += `await import('${source}')
|
|
12650
12669
|
`;
|
|
12670
|
+
}
|
|
12651
12671
|
return code2;
|
|
12652
12672
|
};
|
|
12653
12673
|
function hoistImport(node) {
|
|
@@ -12759,7 +12779,7 @@ async function createBrowserServer(project, options) {
|
|
|
12759
12779
|
});
|
|
12760
12780
|
await server.listen();
|
|
12761
12781
|
await server.watcher.close();
|
|
12762
|
-
(await import('./chunk-api-setup.
|
|
12782
|
+
(await import('./chunk-api-setup.05e3917b.js')).setup(project, server);
|
|
12763
12783
|
return server;
|
|
12764
12784
|
}
|
|
12765
12785
|
|
|
@@ -13060,6 +13080,83 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
13060
13080
|
};
|
|
13061
13081
|
}
|
|
13062
13082
|
|
|
13083
|
+
function resolveOptimizerConfig(testOptionc, viteOptions, testConfig) {
|
|
13084
|
+
var _a;
|
|
13085
|
+
const newConfig = {};
|
|
13086
|
+
const [major, minor] = version$2.split(".").map(Number);
|
|
13087
|
+
const allowed = major >= 5 || major === 4 && minor >= 3;
|
|
13088
|
+
if (!allowed && (testOptionc == null ? void 0 : testOptionc.enabled) === true)
|
|
13089
|
+
console.warn(`Vitest: "deps.optimizer" is only available in Vite >= 4.3.0, current Vite version: ${version$2}`);
|
|
13090
|
+
if (!allowed || (testOptionc == null ? void 0 : testOptionc.enabled) !== true) {
|
|
13091
|
+
newConfig.cacheDir = void 0;
|
|
13092
|
+
newConfig.optimizeDeps = {
|
|
13093
|
+
// experimental in Vite >2.9.2, entries remains to help with older versions
|
|
13094
|
+
disabled: true,
|
|
13095
|
+
entries: []
|
|
13096
|
+
};
|
|
13097
|
+
} else {
|
|
13098
|
+
const cacheDir = testConfig.cache !== false ? (_a = testConfig.cache) == null ? void 0 : _a.dir : null;
|
|
13099
|
+
newConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
|
|
13100
|
+
newConfig.optimizeDeps = {
|
|
13101
|
+
...viteOptions,
|
|
13102
|
+
...testOptionc,
|
|
13103
|
+
noDiscovery: true,
|
|
13104
|
+
disabled: false,
|
|
13105
|
+
entries: [],
|
|
13106
|
+
exclude: ["vitest", ...builtinModules, ...testOptionc.exclude || (viteOptions == null ? void 0 : viteOptions.exclude) || []],
|
|
13107
|
+
include: (testOptionc.include || (viteOptions == null ? void 0 : viteOptions.include) || []).filter((n) => n !== "vitest")
|
|
13108
|
+
};
|
|
13109
|
+
}
|
|
13110
|
+
return newConfig;
|
|
13111
|
+
}
|
|
13112
|
+
function deleteDefineConfig(viteConfig) {
|
|
13113
|
+
const defines = {};
|
|
13114
|
+
if (viteConfig.define) {
|
|
13115
|
+
delete viteConfig.define["import.meta.vitest"];
|
|
13116
|
+
delete viteConfig.define["process.env"];
|
|
13117
|
+
delete viteConfig.define.process;
|
|
13118
|
+
delete viteConfig.define.global;
|
|
13119
|
+
}
|
|
13120
|
+
for (const key in viteConfig.define) {
|
|
13121
|
+
const val = viteConfig.define[key];
|
|
13122
|
+
let replacement;
|
|
13123
|
+
try {
|
|
13124
|
+
replacement = typeof val === "string" ? JSON.parse(val) : val;
|
|
13125
|
+
} catch {
|
|
13126
|
+
continue;
|
|
13127
|
+
}
|
|
13128
|
+
if (key.startsWith("import.meta.env.")) {
|
|
13129
|
+
const envKey = key.slice("import.meta.env.".length);
|
|
13130
|
+
process.env[envKey] = replacement;
|
|
13131
|
+
delete viteConfig.define[key];
|
|
13132
|
+
} else if (key.startsWith("process.env.")) {
|
|
13133
|
+
const envKey = key.slice("process.env.".length);
|
|
13134
|
+
process.env[envKey] = replacement;
|
|
13135
|
+
delete viteConfig.define[key];
|
|
13136
|
+
} else if (!key.includes(".")) {
|
|
13137
|
+
defines[key] = replacement;
|
|
13138
|
+
delete viteConfig.define[key];
|
|
13139
|
+
}
|
|
13140
|
+
}
|
|
13141
|
+
return defines;
|
|
13142
|
+
}
|
|
13143
|
+
|
|
13144
|
+
function VitestResolver(ctx) {
|
|
13145
|
+
return {
|
|
13146
|
+
name: "vitest:resolve-root",
|
|
13147
|
+
enforce: "pre",
|
|
13148
|
+
async resolveId(id) {
|
|
13149
|
+
if (id === "vitest" || id.startsWith("@vitest/")) {
|
|
13150
|
+
return this.resolve(
|
|
13151
|
+
id,
|
|
13152
|
+
join(ctx.config.root, "index.html"),
|
|
13153
|
+
{ skipSelf: true }
|
|
13154
|
+
);
|
|
13155
|
+
}
|
|
13156
|
+
}
|
|
13157
|
+
};
|
|
13158
|
+
}
|
|
13159
|
+
|
|
13063
13160
|
function WorkspaceVitestPlugin(project, options) {
|
|
13064
13161
|
return [
|
|
13065
13162
|
{
|
|
@@ -13068,32 +13165,9 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13068
13165
|
options() {
|
|
13069
13166
|
this.meta.watchMode = false;
|
|
13070
13167
|
},
|
|
13071
|
-
// TODO: refactor so we don't have the same code here and in plugins/index.ts
|
|
13072
13168
|
config(viteConfig) {
|
|
13073
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
13074
|
-
|
|
13075
|
-
delete viteConfig.define["import.meta.vitest"];
|
|
13076
|
-
delete viteConfig.define["process.env"];
|
|
13077
|
-
}
|
|
13078
|
-
const env = {};
|
|
13079
|
-
for (const key in viteConfig.define) {
|
|
13080
|
-
const val = viteConfig.define[key];
|
|
13081
|
-
let replacement;
|
|
13082
|
-
try {
|
|
13083
|
-
replacement = typeof val === "string" ? JSON.parse(val) : val;
|
|
13084
|
-
} catch {
|
|
13085
|
-
continue;
|
|
13086
|
-
}
|
|
13087
|
-
if (key.startsWith("import.meta.env.")) {
|
|
13088
|
-
const envKey = key.slice("import.meta.env.".length);
|
|
13089
|
-
env[envKey] = replacement;
|
|
13090
|
-
delete viteConfig.define[key];
|
|
13091
|
-
} else if (key.startsWith("process.env.")) {
|
|
13092
|
-
const envKey = key.slice("process.env.".length);
|
|
13093
|
-
env[envKey] = replacement;
|
|
13094
|
-
delete viteConfig.define[key];
|
|
13095
|
-
}
|
|
13096
|
-
}
|
|
13169
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13170
|
+
const env = deleteDefineConfig(viteConfig);
|
|
13097
13171
|
const testConfig = viteConfig.test || {};
|
|
13098
13172
|
const root = testConfig.root || viteConfig.root || options.root;
|
|
13099
13173
|
let name = testConfig.name;
|
|
@@ -13148,33 +13222,13 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13148
13222
|
};
|
|
13149
13223
|
}
|
|
13150
13224
|
}
|
|
13151
|
-
const
|
|
13152
|
-
const
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
optimizeConfig.cacheDir = void 0;
|
|
13159
|
-
optimizeConfig.optimizeDeps = {
|
|
13160
|
-
// experimental in Vite >2.9.2, entries remains to help with older versions
|
|
13161
|
-
disabled: true,
|
|
13162
|
-
entries: []
|
|
13163
|
-
};
|
|
13164
|
-
} else {
|
|
13165
|
-
const cacheDir = testConfig.cache !== false ? (_e = testConfig.cache) == null ? void 0 : _e.dir : null;
|
|
13166
|
-
optimizeConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
|
|
13167
|
-
optimizeConfig.optimizeDeps = {
|
|
13168
|
-
...viteConfig.optimizeDeps,
|
|
13169
|
-
...optimizer,
|
|
13170
|
-
noDiscovery: true,
|
|
13171
|
-
disabled: false,
|
|
13172
|
-
entries: [],
|
|
13173
|
-
exclude: ["vitest", ...builtinModules, ...optimizer.exclude || ((_f = viteConfig.optimizeDeps) == null ? void 0 : _f.exclude) || []],
|
|
13174
|
-
include: (optimizer.include || ((_g = viteConfig.optimizeDeps) == null ? void 0 : _g.include) || []).filter((n) => n !== "vitest")
|
|
13175
|
-
};
|
|
13176
|
-
}
|
|
13177
|
-
Object.assign(config, optimizeConfig);
|
|
13225
|
+
const webOptimizer = resolveOptimizerConfig((_e = (_d = testConfig.deps) == null ? void 0 : _d.experimentalOptimizer) == null ? void 0 : _e.web, viteConfig.optimizeDeps, testConfig);
|
|
13226
|
+
const ssrOptimizer = resolveOptimizerConfig((_g = (_f = testConfig.deps) == null ? void 0 : _f.experimentalOptimizer) == null ? void 0 : _g.ssr, (_h = viteConfig.ssr) == null ? void 0 : _h.optimizeDeps, testConfig);
|
|
13227
|
+
config.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || config.cacheDir;
|
|
13228
|
+
config.optimizeDeps = webOptimizer.optimizeDeps;
|
|
13229
|
+
config.ssr = {
|
|
13230
|
+
optimizeDeps: ssrOptimizer.optimizeDeps
|
|
13231
|
+
};
|
|
13178
13232
|
return config;
|
|
13179
13233
|
},
|
|
13180
13234
|
async configureServer(server) {
|
|
@@ -13196,12 +13250,13 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13196
13250
|
...CSSEnablerPlugin(project),
|
|
13197
13251
|
CoverageTransform(project.ctx),
|
|
13198
13252
|
GlobalSetupPlugin(project, project.ctx.logger),
|
|
13199
|
-
MocksPlugin()
|
|
13253
|
+
MocksPlugin(),
|
|
13254
|
+
VitestResolver(project.ctx)
|
|
13200
13255
|
];
|
|
13201
13256
|
}
|
|
13202
13257
|
|
|
13203
13258
|
async function initializeProject(workspacePath, ctx, options) {
|
|
13204
|
-
var _a, _b, _c;
|
|
13259
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13205
13260
|
const project = new WorkspaceProject(workspacePath, ctx);
|
|
13206
13261
|
const configFile = options.extends ? resolve$2(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
|
|
13207
13262
|
const root = options.root || (typeof workspacePath === "number" ? void 0 : dirname(workspacePath));
|
|
@@ -13218,7 +13273,7 @@ async function initializeProject(workspacePath, ctx, options) {
|
|
|
13218
13273
|
]
|
|
13219
13274
|
};
|
|
13220
13275
|
const server = await createServer(config);
|
|
13221
|
-
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_c = (_b = project.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.enabled))
|
|
13276
|
+
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = project.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = project.config.deps) == null ? void 0 : _e.experimentalOptimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
|
|
13222
13277
|
await server.listen();
|
|
13223
13278
|
else
|
|
13224
13279
|
await server.pluginContainer.buildStart({});
|
|
@@ -13387,7 +13442,7 @@ class WorkspaceProject {
|
|
|
13387
13442
|
return isBrowserEnabled(this.config);
|
|
13388
13443
|
}
|
|
13389
13444
|
getSerializableConfig() {
|
|
13390
|
-
var _a, _b;
|
|
13445
|
+
var _a, _b, _c, _d, _e, _f;
|
|
13391
13446
|
return deepMerge(
|
|
13392
13447
|
{
|
|
13393
13448
|
...this.config,
|
|
@@ -13395,8 +13450,13 @@ class WorkspaceProject {
|
|
|
13395
13450
|
reporters: [],
|
|
13396
13451
|
deps: {
|
|
13397
13452
|
...this.config.deps,
|
|
13398
|
-
|
|
13399
|
-
|
|
13453
|
+
optimizer: {
|
|
13454
|
+
web: {
|
|
13455
|
+
enabled: ((_c = (_b = (_a = this.config.deps) == null ? void 0 : _a.experimentalOptimizer) == null ? void 0 : _b.web) == null ? void 0 : _c.enabled) ?? false
|
|
13456
|
+
},
|
|
13457
|
+
ssr: {
|
|
13458
|
+
enabled: ((_f = (_e = (_d = this.config.deps) == null ? void 0 : _d.experimentalOptimizer) == null ? void 0 : _e.ssr) == null ? void 0 : _f.enabled) ?? false
|
|
13459
|
+
}
|
|
13400
13460
|
}
|
|
13401
13461
|
},
|
|
13402
13462
|
snapshotOptions: {
|
|
@@ -14051,47 +14111,22 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14051
14111
|
this.meta.watchMode = false;
|
|
14052
14112
|
},
|
|
14053
14113
|
async config(viteConfig) {
|
|
14054
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
14055
14115
|
if (options.watch) {
|
|
14056
14116
|
options = deepMerge({}, userConfig);
|
|
14057
14117
|
}
|
|
14058
|
-
const
|
|
14118
|
+
const testConfig = deepMerge(
|
|
14059
14119
|
{},
|
|
14060
14120
|
configDefaults,
|
|
14061
14121
|
options,
|
|
14062
14122
|
removeUndefinedValues(viteConfig.test ?? {})
|
|
14063
14123
|
);
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
delete viteConfig.define["import.meta.vitest"];
|
|
14067
|
-
delete viteConfig.define["process.env"];
|
|
14068
|
-
}
|
|
14069
|
-
const defines = {};
|
|
14070
|
-
for (const key in viteConfig.define) {
|
|
14071
|
-
const val = viteConfig.define[key];
|
|
14072
|
-
let replacement;
|
|
14073
|
-
try {
|
|
14074
|
-
replacement = typeof val === "string" ? JSON.parse(val) : val;
|
|
14075
|
-
} catch {
|
|
14076
|
-
continue;
|
|
14077
|
-
}
|
|
14078
|
-
if (key.startsWith("import.meta.env.")) {
|
|
14079
|
-
const envKey = key.slice("import.meta.env.".length);
|
|
14080
|
-
process.env[envKey] = replacement;
|
|
14081
|
-
delete viteConfig.define[key];
|
|
14082
|
-
} else if (key.startsWith("process.env.")) {
|
|
14083
|
-
const envKey = key.slice("process.env.".length);
|
|
14084
|
-
process.env[envKey] = replacement;
|
|
14085
|
-
delete viteConfig.define[key];
|
|
14086
|
-
} else if (!key.includes(".")) {
|
|
14087
|
-
defines[key] = replacement;
|
|
14088
|
-
delete viteConfig.define[key];
|
|
14089
|
-
}
|
|
14090
|
-
}
|
|
14124
|
+
testConfig.api = resolveApiServerConfig(testConfig);
|
|
14125
|
+
const defines = deleteDefineConfig(viteConfig);
|
|
14091
14126
|
options.defines = defines;
|
|
14092
14127
|
let open;
|
|
14093
|
-
if (
|
|
14094
|
-
open =
|
|
14128
|
+
if (testConfig.ui && testConfig.open)
|
|
14129
|
+
open = testConfig.uiBase ?? "/__vitest__/";
|
|
14095
14130
|
const config = {
|
|
14096
14131
|
root: ((_a = viteConfig.test) == null ? void 0 : _a.root) || options.root,
|
|
14097
14132
|
esbuild: {
|
|
@@ -14103,23 +14138,23 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14103
14138
|
// by default Vite resolves `module` field, which not always a native ESM module
|
|
14104
14139
|
// setting this option can bypass that and fallback to cjs version
|
|
14105
14140
|
mainFields: [],
|
|
14106
|
-
alias:
|
|
14141
|
+
alias: testConfig.alias,
|
|
14107
14142
|
conditions: ["node"],
|
|
14108
14143
|
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
14109
14144
|
// @ts-ignore we support Vite ^3.0, but browserField is available in Vite ^3.2
|
|
14110
14145
|
browserField: false
|
|
14111
14146
|
},
|
|
14112
14147
|
server: {
|
|
14113
|
-
...
|
|
14148
|
+
...testConfig.api,
|
|
14114
14149
|
watch: {
|
|
14115
|
-
ignored:
|
|
14150
|
+
ignored: testConfig.watchExclude
|
|
14116
14151
|
},
|
|
14117
14152
|
open,
|
|
14118
14153
|
hmr: false,
|
|
14119
14154
|
preTransformRequests: false
|
|
14120
14155
|
}
|
|
14121
14156
|
};
|
|
14122
|
-
const classNameStrategy = typeof
|
|
14157
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && ((_c = (_b = testConfig.css) == null ? void 0 : _b.modules) == null ? void 0 : _c.classNameStrategy) || "stable";
|
|
14123
14158
|
if (classNameStrategy !== "scoped") {
|
|
14124
14159
|
config.css ?? (config.css = {});
|
|
14125
14160
|
(_d = config.css).modules ?? (_d.modules = {});
|
|
@@ -14130,33 +14165,13 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14130
14165
|
};
|
|
14131
14166
|
}
|
|
14132
14167
|
}
|
|
14133
|
-
const
|
|
14134
|
-
const
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
optimizeConfig.cacheDir = void 0;
|
|
14141
|
-
optimizeConfig.optimizeDeps = {
|
|
14142
|
-
// experimental in Vite >2.9.2, entries remains to help with older versions
|
|
14143
|
-
disabled: true,
|
|
14144
|
-
entries: []
|
|
14145
|
-
};
|
|
14146
|
-
} else {
|
|
14147
|
-
const cacheDir = preOptions.cache !== false ? (_f = preOptions.cache) == null ? void 0 : _f.dir : null;
|
|
14148
|
-
optimizeConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
|
|
14149
|
-
optimizeConfig.optimizeDeps = {
|
|
14150
|
-
...viteConfig.optimizeDeps,
|
|
14151
|
-
...optimizer,
|
|
14152
|
-
noDiscovery: true,
|
|
14153
|
-
disabled: false,
|
|
14154
|
-
entries: [],
|
|
14155
|
-
exclude: ["vitest", ...builtinModules, ...optimizer.exclude || ((_g = viteConfig.optimizeDeps) == null ? void 0 : _g.exclude) || []],
|
|
14156
|
-
include: (optimizer.include || ((_h = viteConfig.optimizeDeps) == null ? void 0 : _h.include) || []).filter((n) => n !== "vitest")
|
|
14157
|
-
};
|
|
14158
|
-
}
|
|
14159
|
-
Object.assign(config, optimizeConfig);
|
|
14168
|
+
const webOptimizer = resolveOptimizerConfig((_f = (_e = testConfig.deps) == null ? void 0 : _e.experimentalOptimizer) == null ? void 0 : _f.web, viteConfig.optimizeDeps, testConfig);
|
|
14169
|
+
const ssrOptimizer = resolveOptimizerConfig((_h = (_g = testConfig.deps) == null ? void 0 : _g.experimentalOptimizer) == null ? void 0 : _h.ssr, (_i = viteConfig.ssr) == null ? void 0 : _i.optimizeDeps, testConfig);
|
|
14170
|
+
config.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || config.cacheDir;
|
|
14171
|
+
config.optimizeDeps = webOptimizer.optimizeDeps;
|
|
14172
|
+
config.ssr = {
|
|
14173
|
+
optimizeDeps: ssrOptimizer.optimizeDeps
|
|
14174
|
+
};
|
|
14160
14175
|
return config;
|
|
14161
14176
|
},
|
|
14162
14177
|
async configResolved(viteConfig) {
|
|
@@ -14191,7 +14206,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14191
14206
|
try {
|
|
14192
14207
|
await ctx.setServer(options, server, userConfig);
|
|
14193
14208
|
if (options.api && options.watch)
|
|
14194
|
-
(await import('./chunk-api-setup.
|
|
14209
|
+
(await import('./chunk-api-setup.05e3917b.js')).setup(ctx);
|
|
14195
14210
|
} catch (err) {
|
|
14196
14211
|
await ctx.logger.printError(err, true);
|
|
14197
14212
|
process.exit(1);
|
|
@@ -14205,12 +14220,13 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
14205
14220
|
...CSSEnablerPlugin(ctx),
|
|
14206
14221
|
CoverageTransform(ctx),
|
|
14207
14222
|
options.ui ? await UIPlugin() : null,
|
|
14208
|
-
MocksPlugin()
|
|
14223
|
+
MocksPlugin(),
|
|
14224
|
+
VitestResolver(ctx)
|
|
14209
14225
|
].filter(notNullish);
|
|
14210
14226
|
}
|
|
14211
14227
|
|
|
14212
14228
|
async function createVitest(mode, options, viteOverrides = {}) {
|
|
14213
|
-
var _a, _b, _c;
|
|
14229
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
14214
14230
|
const ctx = new Vitest(mode);
|
|
14215
14231
|
const root = resolve$2(options.root || process.cwd());
|
|
14216
14232
|
const configPath = options.config === false ? false : options.config ? resolve$2(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
@@ -14222,7 +14238,7 @@ async function createVitest(mode, options, viteOverrides = {}) {
|
|
|
14222
14238
|
plugins: await VitestPlugin(options, ctx)
|
|
14223
14239
|
};
|
|
14224
14240
|
const server = await createServer(mergeConfig(config, mergeConfig(viteOverrides, { root: options.root })));
|
|
14225
|
-
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_c = (_b = ctx.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.enabled))
|
|
14241
|
+
if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = ctx.config.deps) == null ? void 0 : _b.experimentalOptimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = ctx.config.deps) == null ? void 0 : _e.experimentalOptimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
|
|
14226
14242
|
await server.listen();
|
|
14227
14243
|
else
|
|
14228
14244
|
await server.pluginContainer.buildStart({});
|
|
@@ -20606,7 +20622,7 @@ function registerConsoleShortcuts(ctx) {
|
|
|
20606
20622
|
}
|
|
20607
20623
|
|
|
20608
20624
|
async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
20609
|
-
var _a;
|
|
20625
|
+
var _a, _b, _c, _d;
|
|
20610
20626
|
process.env.TEST = "true";
|
|
20611
20627
|
process.env.VITEST = "true";
|
|
20612
20628
|
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = options.mode || "test");
|
|
@@ -20627,10 +20643,12 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
20627
20643
|
options.browser.enabled = true;
|
|
20628
20644
|
const ctx = await createVitest(mode, options, viteOverrides);
|
|
20629
20645
|
if (mode === "test" && ctx.config.coverage.enabled) {
|
|
20630
|
-
const provider = ctx.config.coverage.provider || "
|
|
20646
|
+
const provider = ctx.config.coverage.provider || "v8";
|
|
20631
20647
|
const requiredPackages = CoverageProviderMap[provider];
|
|
20632
20648
|
if (requiredPackages) {
|
|
20633
|
-
|
|
20649
|
+
const defaultProviderInfo = 'Default coverage provider has changed from "c8" to "v8". New package is required to be installed. To use the old deprecated coverage provider use "--coverage.provider c8" option.\nSee https://github.com/vitest-dev/vitest/pull/3339 for more information.\n\n';
|
|
20650
|
+
const isUsingDefaultProvider = ((_c = (_b = ctx.server.config.test) == null ? void 0 : _b.coverage) == null ? void 0 : _c.provider) === void 0 && ((_d = options.coverage) == null ? void 0 : _d.provider) === void 0;
|
|
20651
|
+
if (!await ensurePackageInstalled(requiredPackages, root, isUsingDefaultProvider ? defaultProviderInfo : void 0)) {
|
|
20634
20652
|
process.exitCode = 1;
|
|
20635
20653
|
return ctx;
|
|
20636
20654
|
}
|
|
@@ -20667,4 +20685,4 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
20667
20685
|
return ctx;
|
|
20668
20686
|
}
|
|
20669
20687
|
|
|
20670
|
-
export { BaseSequencer as B, VitestPlugin as V, createVitest as c, divider as d, onetime$1 as o, startVitest as s, version$1 as v };
|
|
20688
|
+
export { BaseSequencer as B, VitestPlugin as V, createVitest as c, divider as d, onetime$1 as o, registerConsoleShortcuts as r, startVitest as s, version$1 as v };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const CoverageProviderMap = {
|
|
2
2
|
c8: "@vitest/coverage-c8",
|
|
3
|
+
v8: "@vitest/coverage-v8",
|
|
3
4
|
istanbul: "@vitest/coverage-istanbul"
|
|
4
5
|
};
|
|
5
6
|
async function resolveCoverageProviderModule(options, loader) {
|
|
6
7
|
if (!(options == null ? void 0 : options.enabled) || !options.provider)
|
|
7
8
|
return null;
|
|
8
9
|
const provider = options.provider;
|
|
9
|
-
if (provider === "c8" || provider === "istanbul") {
|
|
10
|
+
if (provider === "c8" || provider === "v8" || provider === "istanbul") {
|
|
10
11
|
const { default: coverageModule } = await loader.executeId(CoverageProviderMap[provider]);
|
|
11
12
|
if (!coverageModule)
|
|
12
13
|
throw new Error(`Failed to load ${CoverageProviderMap[provider]}. Default export is missing.`);
|