vitest 3.2.3 → 4.0.0-beta.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.
Files changed (50) hide show
  1. package/dist/browser.d.ts +3 -5
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.Cg0miDlQ.js → base.Bj3pWTr1.js} +1 -1
  4. package/dist/chunks/browser.d.q8Z0P0q1.d.ts +18 -0
  5. package/dist/chunks/{cac.Cs_fZ7zn.js → cac.D3EzDDZd.js} +11 -19
  6. package/dist/chunks/{cli-api.C37Ou0i1.js → cli-api.Dn5gKePv.js} +15 -13
  7. package/dist/chunks/{config.d.D2ROskhv.d.ts → config.d.HJdfX-8k.d.ts} +1 -2
  8. package/dist/chunks/{coverage.D1a3dTnj.js → coverage.Cwa-XhJt.js} +68 -26
  9. package/dist/chunks/{defaults.B7q_naMc.js → defaults.CXFFjsi8.js} +2 -42
  10. package/dist/chunks/environment.d.CUq4cUgQ.d.ts +44 -0
  11. package/dist/chunks/{global.d.MAmajcmJ.d.ts → global.d.CVbXEflG.d.ts} +7 -29
  12. package/dist/chunks/{globals.DEHgCU4V.js → globals.Cxal6MLI.js} +1 -1
  13. package/dist/chunks/{index.CJ0plNrh.js → index.B521nVV-.js} +4 -2
  14. package/dist/chunks/{index.CdQS2e2Q.js → index.BWf_gE5n.js} +0 -2
  15. package/dist/chunks/{index.CX5aIIXH.js → index.CZI_8rVt.js} +231 -240
  16. package/dist/chunks/{index.BbB8_kAK.js → index.D-VkfKhf.js} +2 -2
  17. package/dist/chunks/{index.CSxmp_dI.js → index.TfbsX-3I.js} +1 -1
  18. package/dist/chunks/plugin.d.C2EcJUjo.d.ts +9 -0
  19. package/dist/chunks/{reporters.d.DL9pg5DB.d.ts → reporters.d.DxZg19fy.d.ts} +2213 -2207
  20. package/dist/chunks/{rpc.Iovn4oWe.js → rpc.CsFtxqeq.js} +5 -5
  21. package/dist/chunks/{runBaseTests.Dd85QTll.js → runBaseTests.BC7ZIH5L.js} +5 -5
  22. package/dist/chunks/{setup-common.Dd054P77.js → setup-common.D7ZqXFx-.js} +1 -1
  23. package/dist/chunks/{worker.d.DvqK5Vmu.d.ts → worker.d.CmvJfRGs.d.ts} +1 -1
  24. package/dist/chunks/{worker.d.tQu2eJQy.d.ts → worker.d.DoNjFAiv.d.ts} +7 -13
  25. package/dist/cli.js +9 -9
  26. package/dist/config.cjs +2 -49
  27. package/dist/config.d.ts +36 -30
  28. package/dist/config.js +2 -8
  29. package/dist/coverage.d.ts +15 -9
  30. package/dist/coverage.js +7 -6
  31. package/dist/environments.d.ts +2 -3
  32. package/dist/execute.d.ts +3 -5
  33. package/dist/index.d.ts +23 -177
  34. package/dist/index.js +1 -1
  35. package/dist/node.d.ts +38 -26
  36. package/dist/node.js +15 -21
  37. package/dist/reporters.d.ts +9 -9
  38. package/dist/reporters.js +12 -12
  39. package/dist/runners.d.ts +1 -2
  40. package/dist/runners.js +3 -2
  41. package/dist/worker.js +2 -2
  42. package/dist/workers/forks.js +1 -1
  43. package/dist/workers/runVmTests.js +5 -5
  44. package/dist/workers/threads.js +1 -1
  45. package/dist/workers.d.ts +4 -7
  46. package/dist/workers.js +3 -3
  47. package/package.json +16 -16
  48. package/dist/chunks/environment.d.cL3nLXbE.d.ts +0 -119
  49. package/dist/chunks/vite.d.CtvOcEqC.d.ts +0 -25
  50. package/dist/chunks/{typechecker.DRKU1-1g.js → typechecker.CVytUJuF.js} +26 -26
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.D2ROskhv.js';
1
+ import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.HJdfX-8k.js';
2
2
  import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.S9RMNXIe.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
4
  import { VitestExecutor } from './execute.js';
@@ -9,12 +9,10 @@ export { LoupeOptions, ParsedStack, StringifyOptions, format, getSafeTimers, ins
9
9
  export { TraceMap, originalPositionFor } from '@vitest/utils/source-map';
10
10
  import '@vitest/pretty-format';
11
11
  import '@vitest/snapshot';
12
- import '@vitest/snapshot/environment';
13
12
  import 'vite-node/client';
14
13
  import 'vite-node';
15
- import './chunks/worker.d.tQu2eJQy.js';
16
- import './chunks/environment.d.cL3nLXbE.js';
17
- import 'vitest/optional-types.js';
14
+ import './chunks/worker.d.DoNjFAiv.js';
15
+ import './chunks/environment.d.CUq4cUgQ.js';
18
16
  import 'node:vm';
19
17
  import '@vitest/mocker';
20
18
  import './chunks/mocker.d.BE_2ls6u.js';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.Dd054P77.js';
1
+ export { l as loadDiffConfig, b as loadSnapshotSerializers, c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.D7ZqXFx-.js';
2
2
  export { collectTests, processError, startTests } from '@vitest/runner';
3
3
  import * as spy from '@vitest/spy';
4
4
  export { spy as SpyModule };
@@ -24,7 +24,7 @@ async function runBaseTests(method, state) {
24
24
  const [executor, { run }] = await Promise.all([startViteNode({
25
25
  state,
26
26
  requestStubs: getDefaultRequestStubs()
27
- }), import('./runBaseTests.Dd85QTll.js')]);
27
+ }), import('./runBaseTests.BC7ZIH5L.js')]);
28
28
  const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
29
29
  filepath: f,
30
30
  testLocations: void 0
@@ -0,0 +1,18 @@
1
+ import { T as TestExecutionMethod } from './worker.d.DoNjFAiv.js';
2
+
3
+ type SerializedTestSpecification = [project: {
4
+ name: string | undefined
5
+ root: string
6
+ }, file: string, options: {
7
+ pool: string
8
+ testLines?: number[] | undefined
9
+ }];
10
+
11
+ interface BrowserTesterOptions {
12
+ method: TestExecutionMethod;
13
+ files: string[];
14
+ providedContext: string;
15
+ startTime: number;
16
+ }
17
+
18
+ export type { BrowserTesterOptions as B, SerializedTestSpecification as S };
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
5
  import { a as defaultPort, d as defaultBrowserPort } from './constants.DnKduX2e.js';
6
- import { R as ReportersMap } from './index.CX5aIIXH.js';
6
+ import { R as ReportersMap } from './index.CZI_8rVt.js';
7
7
 
8
8
  function toArr(any) {
9
9
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -619,7 +619,7 @@ class CAC extends EventEmitter {
619
619
 
620
620
  const cac = (name = "") => new CAC(name);
621
621
 
622
- var version = "3.2.3";
622
+ var version = "4.0.0-beta.1";
623
623
 
624
624
  const apiConfig = (port) => ({
625
625
  port: {
@@ -734,30 +734,21 @@ const cliOptionsConfig = {
734
734
  argument: "",
735
735
  transform: transformNestedBoolean,
736
736
  subcommands: {
737
- all: {
738
- description: "Whether to include all files, including the untested ones into report",
739
- default: true
740
- },
741
737
  provider: {
742
738
  description: "Select the tool for coverage collection, available values are: \"v8\", \"istanbul\" and \"custom\"",
743
739
  argument: "<name>"
744
740
  },
745
741
  enabled: { description: "Enables coverage collection. Can be overridden using the `--coverage` CLI option (default: `false`)" },
746
742
  include: {
747
- description: "Files included in coverage as glob patterns. May be specified more than once when using multiple patterns (default: `**`)",
743
+ description: "Files included in coverage as glob patterns. May be specified more than once when using multiple patterns. By default only files covered by tests are included.",
748
744
  argument: "<pattern>",
749
745
  array: true
750
746
  },
751
747
  exclude: {
752
- description: "Files to be excluded in coverage. May be specified more than once when using multiple extensions (default: Visit [`coverage.exclude`](https://vitest.dev/config/#coverage-exclude))",
748
+ description: "Files to be excluded in coverage. May be specified more than once when using multiple extensions.",
753
749
  argument: "<pattern>",
754
750
  array: true
755
751
  },
756
- extension: {
757
- description: "Extension to be included in coverage. May be specified more than once when using multiple extensions (default: `[\".js\", \".cjs\", \".mjs\", \".ts\", \".mts\", \".tsx\", \".jsx\", \".vue\", \".svelte\"]`)",
758
- argument: "<extension>",
759
- array: true
760
- },
761
752
  clean: { description: "Clean coverage results before running tests (default: true)" },
762
753
  cleanOnRerun: { description: "Clean coverage report on watch rerun (default: true)" },
763
754
  reportsDirectory: {
@@ -1365,7 +1356,7 @@ function parseCLI(argv, config = {}) {
1365
1356
  arrayArgs.unshift("node");
1366
1357
  let { args, options } = createCLI(config).parse(arrayArgs, { run: false });
1367
1358
  if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev") options.watch = true;
1368
- if (arrayArgs[2] === "run") options.run = true;
1359
+ if (arrayArgs[2] === "run" && !options.watch) options.run = true;
1369
1360
  if (arrayArgs[2] === "related") {
1370
1361
  options.related = args;
1371
1362
  options.passWithNoTests ??= true;
@@ -1386,7 +1377,8 @@ async function watch(cliFilters, options) {
1386
1377
  await start("test", cliFilters, options);
1387
1378
  }
1388
1379
  async function run(cliFilters, options) {
1389
- options.run = true;
1380
+ // "vitest run --watch" should still be watch mode
1381
+ options.run = !options.watch;
1390
1382
  await start("test", cliFilters, options);
1391
1383
  }
1392
1384
  async function benchmark(cliFilters, options) {
@@ -1407,11 +1399,11 @@ async function start(mode, cliFilters, options) {
1407
1399
  process.title = "node (vitest)";
1408
1400
  } catch {}
1409
1401
  try {
1410
- const { startVitest } = await import('./cli-api.C37Ou0i1.js').then(function (n) { return n.f; });
1402
+ const { startVitest } = await import('./cli-api.Dn5gKePv.js').then(function (n) { return n.f; });
1411
1403
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1412
1404
  if (!ctx.shouldKeepServer()) await ctx.exit();
1413
1405
  } catch (e) {
1414
- const { errorBanner } = await import('./index.CX5aIIXH.js').then(function (n) { return n.u; });
1406
+ const { errorBanner } = await import('./index.CZI_8rVt.js').then(function (n) { return n.u; });
1415
1407
  console.error(`\n${errorBanner("Startup Error")}`);
1416
1408
  console.error(e);
1417
1409
  console.error("\n\n");
@@ -1432,7 +1424,7 @@ async function collect(mode, cliFilters, options) {
1432
1424
  process.title = "node (vitest)";
1433
1425
  } catch {}
1434
1426
  try {
1435
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.C37Ou0i1.js').then(function (n) { return n.f; });
1427
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.Dn5gKePv.js').then(function (n) { return n.f; });
1436
1428
  const ctx = await prepareVitest(mode, {
1437
1429
  ...normalizeCliOptions(cliFilters, options),
1438
1430
  watch: false,
@@ -1454,7 +1446,7 @@ async function collect(mode, cliFilters, options) {
1454
1446
  }
1455
1447
  await ctx.close();
1456
1448
  } catch (e) {
1457
- const { errorBanner } = await import('./index.CX5aIIXH.js').then(function (n) { return n.u; });
1449
+ const { errorBanner } = await import('./index.CZI_8rVt.js').then(function (n) { return n.u; });
1458
1450
  console.error(`\n${errorBanner("Collect Error")}`);
1459
1451
  console.error(e);
1460
1452
  console.error("\n\n");
@@ -11,9 +11,9 @@ import { generateFileHash, limitConcurrency, createFileTask, hasFailed, getTasks
11
11
  import { SnapshotManager } from '@vitest/snapshot/manager';
12
12
  import { ViteNodeRunner } from 'vite-node/client';
13
13
  import { ViteNodeServer } from 'vite-node/server';
14
- import { v as version$1 } from './cac.Cs_fZ7zn.js';
15
- import { c as createBirpc } from './index.CJ0plNrh.js';
16
- import { p as parse, s as stringify, d as printError, f as formatProjectName, w as withLabel, e as errorBanner, h as divider, i as generateCodeFrame, R as ReportersMap, j as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.CX5aIIXH.js';
14
+ import { v as version$1 } from './cac.D3EzDDZd.js';
15
+ import { c as createBirpc } from './index.B521nVV-.js';
16
+ import { p as parse, s as stringify, d as printError, f as formatProjectName, w as withLabel, e as errorBanner, h as divider, i as generateCodeFrame, R as ReportersMap, B as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.CZI_8rVt.js';
17
17
  import require$$0$3 from 'events';
18
18
  import require$$1$1 from 'https';
19
19
  import require$$2 from 'http';
@@ -28,8 +28,8 @@ import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
28
28
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
29
29
  import crypto, { createHash } from 'node:crypto';
30
30
  import { distDir, rootDir } from '../path.js';
31
- import { h as hash, R as RandomSequencer, i as isPackageExists, g as getFilePoolName, d as isBrowserEnabled, r as resolveConfig, e as groupBy, f as getCoverageProvider, j as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.D1a3dTnj.js';
32
- import { c as convertTasksToEvents } from './typechecker.DRKU1-1g.js';
31
+ import { h as hash, R as RandomSequencer, i as isPackageExists, g as getFilePoolName, d as isBrowserEnabled, r as resolveConfig, e as groupBy, f as getCoverageProvider, j as createPool, w as wildcardPatternToRegExp, a as resolveApiServerConfig, s as stdout } from './coverage.Cwa-XhJt.js';
32
+ import { c as convertTasksToEvents } from './typechecker.CVytUJuF.js';
33
33
  import { Console } from 'node:console';
34
34
  import c from 'tinyrainbow';
35
35
  import { createRequire } from 'node:module';
@@ -41,9 +41,9 @@ import pm from 'picomatch';
41
41
  import { glob, isDynamicPattern } from 'tinyglobby';
42
42
  import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
43
43
  import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
44
- import { c as configDefaults } from './defaults.B7q_naMc.js';
44
+ import { c as configDefaults } from './defaults.CXFFjsi8.js';
45
45
  import MagicString from 'magic-string';
46
- import { a as BenchmarkReportsMap } from './index.CSxmp_dI.js';
46
+ import { a as BenchmarkReportsMap } from './index.TfbsX-3I.js';
47
47
  import assert$1 from 'node:assert';
48
48
  import { serializeError } from '@vitest/utils/error';
49
49
  import readline from 'node:readline';
@@ -9414,11 +9414,11 @@ class Vitest {
9414
9414
  async resolveProjects(cliOptions) {
9415
9415
  const names = /* @__PURE__ */ new Set();
9416
9416
  if (this.config.projects) {
9417
- if (typeof this.config.workspace !== "undefined") this.logger.warn("Both `config.projects` and `config.workspace` are defined. Ignoring the `workspace` option.");
9417
+ if (typeof this.config.workspace !== "undefined") this.logger.warn("Both `test.projects` and `test.workspace` are defined. Ignoring the `test.workspace` option.");
9418
9418
  return resolveProjects(this, cliOptions, void 0, this.config.projects, names);
9419
9419
  }
9420
9420
  if (Array.isArray(this.config.workspace)) {
9421
- this.logger.deprecate("The `workspace` option is deprecated and will be removed in the next major. To hide this warning, rename `workspace` option to `projects`.");
9421
+ this.logger.deprecate("The `test.workspace` option is deprecated and will be removed in the next major. To hide this warning, rename `test.workspace` option to `test.projects`.");
9422
9422
  return resolveProjects(this, cliOptions, void 0, this.config.workspace, names);
9423
9423
  }
9424
9424
  const workspaceConfigPath = await this.resolveWorkspaceConfigPath();
@@ -9432,7 +9432,7 @@ class Vitest {
9432
9432
  return resolveBrowserProjects(this, new Set([project.name]), [project]);
9433
9433
  }
9434
9434
  const configFile = this.vite.config.configFile ? resolve(this.vite.config.root, this.vite.config.configFile) : "the root config file";
9435
- this.logger.deprecate(`The workspace file is deprecated and will be removed in the next major. Please, use the \`projects\` field in ${configFile} instead.`);
9435
+ this.logger.deprecate(`The workspace file is deprecated and will be removed in the next major. Please, use the \`test.projects\` field in ${configFile} instead.`);
9436
9436
  const workspaceModule = await this.import(workspaceConfigPath);
9437
9437
  if (!workspaceModule.default || !Array.isArray(workspaceModule.default)) throw new TypeError(`Workspace config file "${workspaceConfigPath}" must export a default array of project paths.`);
9438
9438
  return resolveProjects(this, cliOptions, workspaceConfigPath, workspaceModule.default, names);
@@ -10149,6 +10149,9 @@ async function VitestPlugin(options = {}, vitest = new Vitest("test", deepClone(
10149
10149
  for (const name in envs) process.env[name] ??= envs[name];
10150
10150
  // don't watch files in run mode
10151
10151
  if (!options.watch) viteConfig.server.watch = null;
10152
+ if (options.ui)
10153
+ // @ts-expect-error mutate readonly
10154
+ viteConfig.plugins.push(await UIPlugin());
10152
10155
  Object.defineProperty(viteConfig, "_vitest", {
10153
10156
  value: options,
10154
10157
  enumerable: false,
@@ -10174,7 +10177,6 @@ async function VitestPlugin(options = {}, vitest = new Vitest("test", deepClone(
10174
10177
  ...CSSEnablerPlugin(vitest),
10175
10178
  CoverageTransform(vitest),
10176
10179
  VitestCoreResolver(vitest),
10177
- options.ui ? await UIPlugin() : null,
10178
10180
  ...MocksPlugins(),
10179
10181
  VitestOptimizer(),
10180
10182
  NormalizeURLPlugin()
@@ -10631,7 +10633,7 @@ const envPackageNames = {
10631
10633
  function getEnvPackageName(env) {
10632
10634
  if (env === "node") return null;
10633
10635
  if (env in envPackageNames) return envPackageNames[env];
10634
- if (env[0] === "." || env[0] === "/") return null;
10636
+ if (env[0] === "." || isAbsolute(env)) return null;
10635
10637
  return `vitest-environment-${env}`;
10636
10638
  }
10637
10639
 
@@ -10645,4 +10647,4 @@ var cliApi = /*#__PURE__*/Object.freeze({
10645
10647
  startVitest: startVitest
10646
10648
  });
10647
10649
 
10648
- export { FilesNotFoundError as F, GitNotFoundError as G, TestModule as T, Vitest as V, VitestPlugin as a, VitestPackageInstaller as b, createVitest as c, registerConsoleShortcuts as d, createViteLogger as e, cliApi as f, isValidApiRequest as i, resolveFsAllow as r, startVitest as s };
10650
+ export { FilesNotFoundError as F, GitNotFoundError as G, Vitest as V, VitestPlugin as a, VitestPackageInstaller as b, createVitest as c, registerConsoleShortcuts as d, createViteLogger as e, cliApi as f, isValidApiRequest as i, resolveFsAllow as r, startVitest as s };
@@ -1,7 +1,6 @@
1
1
  import { PrettyFormatOptions } from '@vitest/pretty-format';
2
2
  import { SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
3
- import { SnapshotUpdateState } from '@vitest/snapshot';
4
- import { SnapshotEnvironment } from '@vitest/snapshot/environment';
3
+ import { SnapshotUpdateState, SnapshotEnvironment } from '@vitest/snapshot';
5
4
  import { SerializedDiffOptions } from '@vitest/utils/diff';
6
5
 
7
6
  /**
@@ -1,12 +1,14 @@
1
1
  import fs, { statSync, realpathSync, promises as promises$1, mkdirSync, existsSync, readdirSync, writeFileSync } from 'node:fs';
2
+ import path, { win32, dirname, join, resolve } from 'node:path';
2
3
  import { isAbsolute, join as join$1, dirname as dirname$1, resolve as resolve$1, relative, normalize } from 'pathe';
3
4
  import pm from 'picomatch';
5
+ import { glob } from 'tinyglobby';
4
6
  import c from 'tinyrainbow';
5
- import { c as configDefaults, e as benchmarkConfigDefaults, a as coverageConfigDefaults } from './defaults.B7q_naMc.js';
7
+ import { slash, cleanUrl } from 'vite-node/utils';
8
+ import { c as configDefaults, e as benchmarkConfigDefaults, a as coverageConfigDefaults } from './defaults.CXFFjsi8.js';
6
9
  import crypto from 'node:crypto';
7
- import { createDefer, shuffle, toArray } from '@vitest/utils';
10
+ import { createDefer, shuffle, toArray, slash as slash$1 } from '@vitest/utils';
8
11
  import { builtinModules, createRequire } from 'node:module';
9
- import path, { win32, dirname, join, resolve } from 'node:path';
10
12
  import process$1 from 'node:process';
11
13
  import fs$1, { writeFile, rename, stat, unlink } from 'node:fs/promises';
12
14
  import { fileURLToPath as fileURLToPath$1, pathToFileURL as pathToFileURL$1, URL as URL$1 } from 'node:url';
@@ -14,19 +16,18 @@ import assert from 'node:assert';
14
16
  import v8 from 'node:v8';
15
17
  import { format, inspect } from 'node:util';
16
18
  import { version, mergeConfig } from 'vite';
17
- import { e as extraInlineDeps, d as defaultBrowserPort, b as defaultInspectPort, a as defaultPort } from './constants.DnKduX2e.js';
19
+ import { c as configFiles, w as workspacesFiles, e as extraInlineDeps, d as defaultBrowserPort, b as defaultInspectPort, a as defaultPort } from './constants.DnKduX2e.js';
18
20
  import { a as isWindows } from './env.D4Lgay0q.js';
19
21
  import * as nodeos from 'node:os';
20
22
  import nodeos__default from 'node:os';
21
23
  import { isatty } from 'node:tty';
22
24
  import EventEmitter from 'node:events';
23
- import { c as createBirpc } from './index.CJ0plNrh.js';
25
+ import { c as createBirpc } from './index.B521nVV-.js';
24
26
  import Tinypool$1, { Tinypool } from 'tinypool';
25
- import { w as wrapSerializableConfig, a as Typechecker } from './typechecker.DRKU1-1g.js';
27
+ import { w as wrapSerializableConfig, a as Typechecker } from './typechecker.CVytUJuF.js';
26
28
  import { MessageChannel } from 'node:worker_threads';
27
29
  import { hasFailed } from '@vitest/runner/utils';
28
30
  import { rootDir } from '../path.js';
29
- import { slash } from 'vite-node/utils';
30
31
  import { isCI, provider } from 'std-env';
31
32
  import { r as resolveCoverageProviderModule } from './coverage.DVF1vEu8.js';
32
33
 
@@ -2450,14 +2451,6 @@ function createMethodsRPC(project, options = {}) {
2450
2451
  resolveSnapshotPath(testPath) {
2451
2452
  return ctx.snapshot.resolvePath(testPath, { config: project.serializedConfig });
2452
2453
  },
2453
- async getSourceMap(id, force) {
2454
- if (force) {
2455
- const mod = project.vite.moduleGraph.getModuleById(id);
2456
- if (mod) project.vite.moduleGraph.invalidateModule(mod);
2457
- }
2458
- const r = await project.vitenode.transformRequest(id);
2459
- return r?.map;
2460
- },
2461
2454
  async fetch(id, transformMode) {
2462
2455
  const result = await project.vitenode.fetchResult(id, transformMode).catch(handleRollupError);
2463
2456
  const code = result.code;
@@ -2610,7 +2603,7 @@ function createForksPool(vitest, { execArgv, env }) {
2610
2603
  const threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
2611
2604
  const poolOptions = vitest.config.poolOptions?.forks ?? {};
2612
2605
  const maxThreads = poolOptions.maxForks ?? vitest.config.maxWorkers ?? threadsCount;
2613
- const minThreads = poolOptions.minForks ?? vitest.config.minWorkers ?? threadsCount;
2606
+ const minThreads = poolOptions.minForks ?? vitest.config.minWorkers ?? Math.min(threadsCount, maxThreads);
2614
2607
  const worker = resolve(vitest.distPath, "workers/forks.js");
2615
2608
  const options = {
2616
2609
  runtime: "child_process",
@@ -2746,7 +2739,7 @@ function createThreadsPool(vitest, { execArgv, env }) {
2746
2739
  const threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
2747
2740
  const poolOptions = vitest.config.poolOptions?.threads ?? {};
2748
2741
  const maxThreads = poolOptions.maxThreads ?? vitest.config.maxWorkers ?? threadsCount;
2749
- const minThreads = poolOptions.minThreads ?? vitest.config.minWorkers ?? threadsCount;
2742
+ const minThreads = poolOptions.minThreads ?? vitest.config.minWorkers ?? Math.min(threadsCount, maxThreads);
2750
2743
  const worker = resolve(vitest.distPath, "workers/threads.js");
2751
2744
  const options = {
2752
2745
  filename: resolve(vitest.distPath, "worker.js"),
@@ -3074,7 +3067,7 @@ function createVmForksPool(vitest, { execArgv, env }) {
3074
3067
  const threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
3075
3068
  const poolOptions = vitest.config.poolOptions?.vmForks ?? {};
3076
3069
  const maxThreads = poolOptions.maxForks ?? vitest.config.maxWorkers ?? threadsCount;
3077
- const minThreads = poolOptions.maxForks ?? vitest.config.minWorkers ?? threadsCount;
3070
+ const minThreads = poolOptions.maxForks ?? vitest.config.minWorkers ?? Math.min(threadsCount, maxThreads);
3078
3071
  const worker = resolve(vitest.distPath, "workers/vmForks.js");
3079
3072
  const options = {
3080
3073
  runtime: "child_process",
@@ -3194,7 +3187,7 @@ function createVmThreadsPool(vitest, { execArgv, env }) {
3194
3187
  const threadsCount = vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
3195
3188
  const poolOptions = vitest.config.poolOptions?.vmThreads ?? {};
3196
3189
  const maxThreads = poolOptions.maxThreads ?? vitest.config.maxWorkers ?? threadsCount;
3197
- const minThreads = poolOptions.minThreads ?? vitest.config.minWorkers ?? threadsCount;
3190
+ const minThreads = poolOptions.minThreads ?? vitest.config.minWorkers ?? Math.min(threadsCount, maxThreads);
3198
3191
  const worker = resolve(vitest.distPath, "workers/vmThreads.js");
3199
3192
  const options = {
3200
3193
  filename: resolve(vitest.distPath, "worker.js"),
@@ -3301,7 +3294,7 @@ function getDefaultPoolName(project) {
3301
3294
  }
3302
3295
  function getFilePoolName(project, file) {
3303
3296
  for (const [glob, pool] of project.config.poolMatchGlobs) {
3304
- if (pool === "browser") throw new Error("Since Vitest 0.31.0 \"browser\" pool is not supported in \"poolMatchGlobs\". You can create a project to run some of your tests in browser in parallel. Read more: https://vitest.dev/guide/projects");
3297
+ if (pool === "browser") throw new Error("Since Vitest 0.31.0 \"browser\" pool is not supported in `poolMatchGlobs`. You can create a project to run some of your tests in browser in parallel. Read more: https://vitest.dev/guide/projects");
3305
3298
  if (pm.isMatch(file, glob, { cwd: project.config.root })) return pool;
3306
3299
  }
3307
3300
  return getDefaultPoolName(project);
@@ -3396,7 +3389,10 @@ function createPool(ctx) {
3396
3389
  const Sequencer = ctx.config.sequence.sequencer;
3397
3390
  const sequencer = new Sequencer(ctx);
3398
3391
  async function sortSpecs(specs) {
3399
- if (ctx.config.shard) specs = await sequencer.shard(specs);
3392
+ if (ctx.config.shard) {
3393
+ if (!ctx.config.passWithNoTests && ctx.config.shard.count > specs.length) throw new Error(`--shard <count> must be a smaller than count of test files. Resolved ${specs.length} test files for --shard=${ctx.config.shard.index}/${ctx.config.shard.count}.`);
3394
+ specs = await sequencer.shard(specs);
3395
+ }
3400
3396
  return sequencer.sort(specs);
3401
3397
  }
3402
3398
  const sortedGroups = Array.from(groups).sort();
@@ -3649,12 +3645,19 @@ function resolveConfig$1(vitest, options, viteConfig) {
3649
3645
  resolved.deps.web.transformGlobPattern ??= [];
3650
3646
  resolved.setupFiles = toArray(resolved.setupFiles || []).map((file) => resolvePath(file, resolved.root));
3651
3647
  resolved.globalSetup = toArray(resolved.globalSetup || []).map((file) => resolvePath(file, resolved.root));
3652
- // override original exclude array for cases where user re-uses same object in test.exclude
3648
+ // Add hard-coded default coverage exclusions. These cannot be overidden by user config.
3649
+ // Override original exclude array for cases where user re-uses same object in test.exclude.
3653
3650
  resolved.coverage.exclude = [
3654
3651
  ...resolved.coverage.exclude,
3655
3652
  ...resolved.setupFiles.map((file) => `${resolved.coverage.allowExternal ? "**/" : ""}${relative(resolved.root, file)}`),
3656
- ...resolved.include
3657
- ];
3653
+ ...resolved.include,
3654
+ resolved.config && slash$1(resolved.config),
3655
+ ...configFiles,
3656
+ ...workspacesFiles,
3657
+ "**/virtual:*",
3658
+ "**/__x00__*",
3659
+ "**/node_modules/**"
3660
+ ].filter((pattern) => pattern != null);
3658
3661
  resolved.forceRerunTriggers = [...resolved.forceRerunTriggers, ...resolved.setupFiles];
3659
3662
  resolved.server ??= {};
3660
3663
  resolved.server.deps ??= {};
@@ -3767,7 +3770,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
3767
3770
  // if passed down from the CLI and it's relative, resolve relative to CWD
3768
3771
  resolved.workspace = typeof options.workspace === "string" && options.workspace[0] === "." ? resolve$1(process.cwd(), options.workspace) : resolvePath(resolved.workspace, resolved.root);
3769
3772
  if (!builtinPools.includes(resolved.pool)) resolved.pool = resolvePath(resolved.pool, resolved.root);
3770
- if (resolved.poolMatchGlobs) logger.warn(c.yellow(`${c.inverse(c.yellow(" Vitest "))} "poolMatchGlobs" is deprecated. Use "workspace" to define different configurations instead.`));
3773
+ if (resolved.poolMatchGlobs) logger.deprecate("`poolMatchGlobs` is deprecated. Use `test.projects` to define different configurations instead.");
3771
3774
  resolved.poolMatchGlobs = (resolved.poolMatchGlobs || []).map(([glob, pool]) => {
3772
3775
  if (!builtinPools.includes(pool)) pool = resolvePath(pool, resolved.root);
3773
3776
  return [glob, pool];
@@ -3869,7 +3872,7 @@ function resolveConfig$1(vitest, options, viteConfig) {
3869
3872
  ...configDefaults.typecheck,
3870
3873
  ...resolved.typecheck
3871
3874
  };
3872
- if (resolved.environmentMatchGlobs) logger.warn(c.yellow(`${c.inverse(c.yellow(" Vitest "))} "environmentMatchGlobs" is deprecated. Use "workspace" to define different configurations instead.`));
3875
+ if (resolved.environmentMatchGlobs) logger.deprecate("\"environmentMatchGlobs\" is deprecated. Use `test.projects` to define different configurations instead.");
3873
3876
  resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve$1(resolved.root, i[0]), i[1]]);
3874
3877
  resolved.typecheck ??= {};
3875
3878
  resolved.typecheck.enabled ??= false;
@@ -3959,6 +3962,7 @@ class BaseCoverageProvider {
3959
3962
  name;
3960
3963
  version;
3961
3964
  options;
3965
+ globCache = /* @__PURE__ */ new Map();
3962
3966
  coverageFiles = /* @__PURE__ */ new Map();
3963
3967
  pendingPromises = [];
3964
3968
  coverageFilesDirectory;
@@ -3986,6 +3990,44 @@ Update your dependencies and make sure the versions match.`));
3986
3990
  const tempDirectory = `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`;
3987
3991
  this.coverageFilesDirectory = resolve$1(this.options.reportsDirectory, tempDirectory);
3988
3992
  }
3993
+ /**
3994
+ * Check if file matches `coverage.include` but not `coverage.exclude`
3995
+ */
3996
+ isIncluded(_filename) {
3997
+ const filename = slash(_filename);
3998
+ const cacheHit = this.globCache.get(filename);
3999
+ if (cacheHit !== void 0) return cacheHit;
4000
+ // File outside project root with default allowExternal
4001
+ if (this.options.allowExternal === false && !filename.startsWith(this.ctx.config.root)) {
4002
+ this.globCache.set(filename, false);
4003
+ return false;
4004
+ }
4005
+ const options = {
4006
+ contains: true,
4007
+ dot: true,
4008
+ cwd: this.ctx.config.root,
4009
+ ignore: this.options.exclude
4010
+ };
4011
+ // By default `coverage.include` matches all files, except "coverage.exclude"
4012
+ const glob = this.options.include || "**";
4013
+ const included = pm.isMatch(filename, glob, options) && existsSync(cleanUrl(filename));
4014
+ this.globCache.set(filename, included);
4015
+ return included;
4016
+ }
4017
+ async getUntestedFiles(testedFiles) {
4018
+ if (this.options.include == null) return [];
4019
+ let includedFiles = await glob(this.options.include, {
4020
+ cwd: this.ctx.config.root,
4021
+ ignore: [...this.options.exclude, ...testedFiles.map((file) => slash(file))],
4022
+ absolute: true,
4023
+ dot: true,
4024
+ onlyFiles: true
4025
+ });
4026
+ // Run again through picomatch as tinyglobby's exclude pattern is different ({ "exclude": ["math"] } should ignore "src/math.ts")
4027
+ includedFiles = includedFiles.filter((file) => this.isIncluded(file));
4028
+ if (this.ctx.config.changed) includedFiles = (this.ctx.config.related || []).filter((file) => includedFiles.includes(file));
4029
+ return includedFiles.map((file) => slash(path.resolve(this.ctx.config.root, file)));
4030
+ }
3989
4031
  createCoverageMap() {
3990
4032
  throw new Error("BaseReporter's createCoverageMap was not overwritten");
3991
4033
  }
@@ -3,13 +3,7 @@ import './env.D4Lgay0q.js';
3
3
  import { isCI } from 'std-env';
4
4
 
5
5
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
6
- const defaultExclude = [
7
- "**/node_modules/**",
8
- "**/dist/**",
9
- "**/cypress/**",
10
- "**/.{idea,git,cache,output,temp}/**",
11
- "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
12
- ];
6
+ const defaultExclude = ["**/node_modules/**", "**/.git/**"];
13
7
  const benchmarkConfigDefaults = {
14
8
  include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
15
9
  exclude: defaultExclude,
@@ -17,34 +11,14 @@ const benchmarkConfigDefaults = {
17
11
  reporters: ["default"],
18
12
  includeSamples: false
19
13
  };
20
- const defaultCoverageExcludes = [
21
- "coverage/**",
22
- "dist/**",
23
- "**/node_modules/**",
24
- "**/[.]**",
25
- "packages/*/test?(s)/**",
26
- "**/*.d.ts",
27
- "**/virtual:*",
28
- "**/__x00__*",
29
- "**/\0*",
30
- "cypress/**",
31
- "test?(s)/**",
32
- "test?(-*).?(c|m)[jt]s?(x)",
33
- "**/*{.,-}{test,spec,bench,benchmark}?(-d).?(c|m)[jt]s?(x)",
34
- "**/__tests__/**",
35
- "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*",
36
- "**/vitest.{workspace,projects}.[jt]s?(on)",
37
- "**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
38
- ];
39
14
  // These are the generic defaults for coverage. Providers may also set some provider specific defaults.
40
15
  const coverageConfigDefaults = {
41
16
  provider: "v8",
42
17
  enabled: false,
43
- all: true,
44
18
  clean: true,
45
19
  cleanOnRerun: true,
46
20
  reportsDirectory: "./coverage",
47
- exclude: defaultCoverageExcludes,
21
+ exclude: [],
48
22
  reportOnFailure: false,
49
23
  reporter: [
50
24
  ["text", {}],
@@ -52,22 +26,8 @@ const coverageConfigDefaults = {
52
26
  ["clover", {}],
53
27
  ["json", {}]
54
28
  ],
55
- extension: [
56
- ".js",
57
- ".cjs",
58
- ".mjs",
59
- ".ts",
60
- ".mts",
61
- ".tsx",
62
- ".jsx",
63
- ".vue",
64
- ".svelte",
65
- ".marko",
66
- ".astro"
67
- ],
68
29
  allowExternal: false,
69
30
  excludeAfterRemap: false,
70
- ignoreEmptyLines: true,
71
31
  processingConcurrency: Math.min(20, nodeos__default.availableParallelism?.() ?? nodeos__default.cpus().length)
72
32
  };
73
33
  const fakeTimersDefaults = {
@@ -0,0 +1,44 @@
1
+ type Awaitable<T> = T | PromiseLike<T>;
2
+ type Arrayable<T> = T | Array<T>;
3
+ type TransformMode = "web" | "ssr";
4
+ interface AfterSuiteRunMeta {
5
+ coverage?: unknown;
6
+ testFiles: string[];
7
+ transformMode: TransformMode | "browser";
8
+ projectName?: string;
9
+ }
10
+ interface UserConsoleLog {
11
+ content: string;
12
+ origin?: string;
13
+ browser?: boolean;
14
+ type: "stdout" | "stderr";
15
+ taskId?: string;
16
+ time: number;
17
+ size: number;
18
+ }
19
+ interface ModuleGraphData {
20
+ graph: Record<string, string[]>;
21
+ externalized: string[];
22
+ inlined: string[];
23
+ }
24
+ interface ProvidedContext {}
25
+ // These need to be compatible with Tinyrainbow's bg-colors, and CSS's background-color
26
+ type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
27
+
28
+ interface EnvironmentReturn {
29
+ teardown: (global: any) => Awaitable<void>;
30
+ }
31
+ interface VmEnvironmentReturn {
32
+ getVmContext: () => {
33
+ [key: string]: any
34
+ };
35
+ teardown: () => Awaitable<void>;
36
+ }
37
+ interface Environment {
38
+ name: string;
39
+ transformMode: "web" | "ssr";
40
+ setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
41
+ setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
42
+ }
43
+
44
+ export type { AfterSuiteRunMeta as A, Environment as E, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, TransformMode as T, UserConsoleLog as U, VmEnvironmentReturn as V, EnvironmentReturn as a, Awaitable as b, Arrayable as c };
@@ -2,40 +2,20 @@ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
2
2
  import { Plugin } from '@vitest/pretty-format';
3
3
  import { SnapshotState } from '@vitest/snapshot';
4
4
  import { B as BenchmarkResult } from './benchmark.d.BwvBVTda.js';
5
- import { U as UserConsoleLog } from './environment.d.cL3nLXbE.js';
6
-
7
- type RawErrsMap = Map<string, TscErrorInfo[]>;
8
- interface TscErrorInfo {
9
- filePath: string;
10
- errCode: number;
11
- errMsg: string;
12
- line: number;
13
- column: number;
14
- }
15
- interface CollectLineNumbers {
16
- target: number;
17
- next: number;
18
- prev?: number;
19
- }
20
- type CollectLines = { [key in keyof CollectLineNumbers] : string };
21
- interface RootAndTarget {
22
- root: string;
23
- targetAbsPath: string;
24
- }
25
- type Context = RootAndTarget & {
26
- rawErrsMap: RawErrsMap
27
- openedDirs: Set<string>
28
- lastActivePath?: string
29
- };
5
+ import { U as UserConsoleLog } from './environment.d.CUq4cUgQ.js';
30
6
 
31
7
  declare global {
32
8
  // eslint-disable-next-line ts/no-namespace
33
9
  namespace Chai {
10
+ interface ContainSubset {
11
+ (expected: any): Assertion;
12
+ }
34
13
  interface Assertion {
35
- containSubset: (expected: any) => Assertion;
14
+ containSubset: ContainSubset;
36
15
  }
37
16
  interface Assert {
38
- containSubset: (val: any, exp: any, msg?: string) => void;
17
+ // eslint-disable-next-line ts/method-signature-style
18
+ containSubset(val: any, exp: any, msg?: string): void;
39
19
  }
40
20
  }
41
21
  }
@@ -132,5 +112,3 @@ declare module "@vitest/runner" {
132
112
  benchmark?: BenchmarkResult;
133
113
  }
134
114
  }
135
-
136
- export type { CollectLineNumbers as C, RawErrsMap as R, TscErrorInfo as T, CollectLines as a, RootAndTarget as b, Context as c };
@@ -1,5 +1,5 @@
1
1
  import { g as globalApis } from './constants.DnKduX2e.js';
2
- import { V as VitestIndex } from './index.CdQS2e2Q.js';
2
+ import { V as VitestIndex } from './index.BWf_gE5n.js';
3
3
  import './vi.bdSIJ99Y.js';
4
4
  import '@vitest/expect';
5
5
  import '@vitest/runner';