vitest 3.2.4 → 4.0.0-beta.2

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.DfmxU-tU.js → base.Bj3pWTr1.js} +1 -1
  4. package/dist/chunks/browser.d.DP0ACFkh.d.ts +18 -0
  5. package/dist/chunks/{cac.Cb-PYCCB.js → cac.CVVvMokL.js} +8 -19
  6. package/dist/chunks/{cli-api.BkDphVBG.js → cli-api.BUkNuHvl.js} +23 -22
  7. package/dist/chunks/{config.d.D2ROskhv.d.ts → config.d.HJdfX-8k.d.ts} +1 -2
  8. package/dist/chunks/{coverage.DL5VHqXY.js → coverage.BjMqihzx.js} +58 -37
  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.CdQS2e2Q.js → index.BWf_gE5n.js} +0 -2
  14. package/dist/chunks/{index.BCWujgDG.js → index.CJvUWPky.js} +1 -1
  15. package/dist/chunks/{index.CwejwG0H.js → index.D-VkfKhf.js} +2 -2
  16. package/dist/chunks/{index.VByaPkjc.js → index.a-yuRg2G.js} +223 -236
  17. package/dist/chunks/plugin.d.NmsBIHuT.d.ts +9 -0
  18. package/dist/chunks/{reporters.d.BFLkQcL6.d.ts → reporters.d.BbsDWlO9.d.ts} +2191 -2211
  19. package/dist/chunks/{rpc.-pEldfrD.js → rpc.CsFtxqeq.js} +4 -4
  20. package/dist/chunks/{runBaseTests.9Ij9_de-.js → runBaseTests.BC7ZIH5L.js} +4 -4
  21. package/dist/chunks/{setup-common.Dd054P77.js → setup-common.D7ZqXFx-.js} +1 -1
  22. package/dist/chunks/{worker.d.1GmBbd7G.d.ts → worker.d.COAQvn4k.d.ts} +6 -19
  23. package/dist/chunks/{worker.d.CKwWzBSj.d.ts → worker.d.CVn8WGlF.d.ts} +1 -1
  24. package/dist/cli.js +9 -9
  25. package/dist/config.cjs +2 -49
  26. package/dist/config.d.ts +36 -30
  27. package/dist/config.js +2 -8
  28. package/dist/coverage.d.ts +15 -9
  29. package/dist/coverage.js +6 -5
  30. package/dist/environments.d.ts +2 -3
  31. package/dist/execute.d.ts +3 -5
  32. package/dist/index.d.ts +24 -181
  33. package/dist/index.js +1 -1
  34. package/dist/node.d.ts +37 -28
  35. package/dist/node.js +13 -19
  36. package/dist/reporters.d.ts +9 -9
  37. package/dist/reporters.js +12 -12
  38. package/dist/runners.d.ts +1 -2
  39. package/dist/runners.js +10 -2
  40. package/dist/worker.js +1 -1
  41. package/dist/workers/forks.js +1 -1
  42. package/dist/workers/runVmTests.js +4 -4
  43. package/dist/workers/threads.js +1 -1
  44. package/dist/workers.d.ts +4 -7
  45. package/dist/workers.js +2 -2
  46. package/globals.d.ts +17 -17
  47. package/package.json +12 -12
  48. package/dist/chunks/environment.d.cL3nLXbE.d.ts +0 -119
  49. package/dist/chunks/vite.d.CMLlLIFP.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.1GmBbd7G.js';
16
- import './chunks/environment.d.cL3nLXbE.js';
17
- import 'vitest/optional-types.js';
14
+ import './chunks/worker.d.COAQvn4k.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.9Ij9_de-.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.COAQvn4k.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.VByaPkjc.js';
6
+ import { R as ReportersMap } from './index.a-yuRg2G.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.4";
622
+ var version = "4.0.0-beta.2";
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: {
@@ -1210,7 +1201,6 @@ const cliOptionsConfig = {
1210
1201
  includeSource: null,
1211
1202
  alias: null,
1212
1203
  env: null,
1213
- environmentMatchGlobs: null,
1214
1204
  environmentOptions: null,
1215
1205
  unstubEnvs: null,
1216
1206
  related: null,
@@ -1227,7 +1217,6 @@ const cliOptionsConfig = {
1227
1217
  chaiConfig: null,
1228
1218
  clearMocks: null,
1229
1219
  css: null,
1230
- poolMatchGlobs: null,
1231
1220
  deps: null,
1232
1221
  name: null,
1233
1222
  snapshotEnvironment: null,
@@ -1408,11 +1397,11 @@ async function start(mode, cliFilters, options) {
1408
1397
  process.title = "node (vitest)";
1409
1398
  } catch {}
1410
1399
  try {
1411
- const { startVitest } = await import('./cli-api.BkDphVBG.js').then(function (n) { return n.f; });
1400
+ const { startVitest } = await import('./cli-api.BUkNuHvl.js').then(function (n) { return n.f; });
1412
1401
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1413
1402
  if (!ctx.shouldKeepServer()) await ctx.exit();
1414
1403
  } catch (e) {
1415
- const { errorBanner } = await import('./index.VByaPkjc.js').then(function (n) { return n.u; });
1404
+ const { errorBanner } = await import('./index.a-yuRg2G.js').then(function (n) { return n.u; });
1416
1405
  console.error(`\n${errorBanner("Startup Error")}`);
1417
1406
  console.error(e);
1418
1407
  console.error("\n\n");
@@ -1433,7 +1422,7 @@ async function collect(mode, cliFilters, options) {
1433
1422
  process.title = "node (vitest)";
1434
1423
  } catch {}
1435
1424
  try {
1436
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BkDphVBG.js').then(function (n) { return n.f; });
1425
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BUkNuHvl.js').then(function (n) { return n.f; });
1437
1426
  const ctx = await prepareVitest(mode, {
1438
1427
  ...normalizeCliOptions(cliFilters, options),
1439
1428
  watch: false,
@@ -1455,7 +1444,7 @@ async function collect(mode, cliFilters, options) {
1455
1444
  }
1456
1445
  await ctx.close();
1457
1446
  } catch (e) {
1458
- const { errorBanner } = await import('./index.VByaPkjc.js').then(function (n) { return n.u; });
1447
+ const { errorBanner } = await import('./index.a-yuRg2G.js').then(function (n) { return n.u; });
1459
1448
  console.error(`\n${errorBanner("Collect Error")}`);
1460
1449
  console.error(e);
1461
1450
  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.Cb-PYCCB.js';
14
+ import { v as version$1 } from './cac.CVVvMokL.js';
15
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, j as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.VByaPkjc.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.a-yuRg2G.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.DL5VHqXY.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.BjMqihzx.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.BCWujgDG.js';
46
+ import { a as BenchmarkReportsMap } from './index.CJvUWPky.js';
47
47
  import assert$1 from 'node:assert';
48
48
  import { serializeError } from '@vitest/utils/error';
49
49
  import readline from 'node:readline';
@@ -5120,9 +5120,6 @@ function setup(ctx, _server) {
5120
5120
  getConfig() {
5121
5121
  return ctx.getRootProject().serializedConfig;
5122
5122
  },
5123
- getResolvedProjectNames() {
5124
- return ctx.projects.map((p) => p.name);
5125
- },
5126
5123
  getResolvedProjectLabels() {
5127
5124
  return ctx.projects.map((p) => ({
5128
5125
  name: p.name,
@@ -6991,7 +6988,7 @@ class TestProject {
6991
6988
  * @param moduleId The file path
6992
6989
  */
6993
6990
  createSpecification(moduleId, locations, pool) {
6994
- return new TestSpecification(this, moduleId, pool || getFilePoolName(this, moduleId), locations);
6991
+ return new TestSpecification(this, moduleId, pool || getFilePoolName(this), locations);
6995
6992
  }
6996
6993
  toJSON() {
6997
6994
  return {
@@ -8244,25 +8241,29 @@ class StateManager {
8244
8241
  processTimeoutCauses = /* @__PURE__ */ new Set();
8245
8242
  reportedTasksMap = /* @__PURE__ */ new WeakMap();
8246
8243
  blobs;
8247
- catchError(err, type) {
8248
- if (isAggregateError(err)) return err.errors.forEach((error) => this.catchError(error, type));
8249
- if (err === Object(err)) err.type = type;
8250
- else err = {
8244
+ onUnhandledError;
8245
+ constructor(options) {
8246
+ this.onUnhandledError = options.onUnhandledError;
8247
+ }
8248
+ catchError(error, type) {
8249
+ if (isAggregateError(error)) return error.errors.forEach((error) => this.catchError(error, type));
8250
+ if (typeof error === "object" && error !== null) error.type = type;
8251
+ else error = {
8251
8252
  type,
8252
- message: err
8253
+ message: error
8253
8254
  };
8254
- const _err = err;
8255
- if (_err && typeof _err === "object" && _err.code === "VITEST_PENDING") {
8256
- const task = this.idMap.get(_err.taskId);
8255
+ const _error = error;
8256
+ if (_error && typeof _error === "object" && _error.code === "VITEST_PENDING") {
8257
+ const task = this.idMap.get(_error.taskId);
8257
8258
  if (task) {
8258
8259
  task.mode = "skip";
8259
8260
  task.result ??= { state: "skip" };
8260
8261
  task.result.state = "skip";
8261
- task.result.note = _err.note;
8262
+ task.result.note = _error.note;
8262
8263
  }
8263
8264
  return;
8264
8265
  }
8265
- this.errorsSet.add(err);
8266
+ if (!this.onUnhandledError || this.onUnhandledError(error) !== false) this.errorsSet.add(error);
8266
8267
  }
8267
8268
  clearErrors() {
8268
8269
  this.errorsSet.clear();
@@ -9274,7 +9275,7 @@ class Vitest {
9274
9275
  this._vite = server;
9275
9276
  const resolved = resolveConfig(this, options, server.config);
9276
9277
  this._config = resolved;
9277
- this._state = new StateManager();
9278
+ this._state = new StateManager({ onUnhandledError: resolved.onUnhandledError });
9278
9279
  this._cache = new VitestCache(this.version);
9279
9280
  this._snapshot = new SnapshotManager({ ...resolved.snapshotOptions });
9280
9281
  this._testRun = new TestRun(this);
@@ -10647,4 +10648,4 @@ var cliApi = /*#__PURE__*/Object.freeze({
10647
10648
  startVitest: startVitest
10648
10649
  });
10649
10650
 
10650
- 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 };
10651
+ 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,7 +16,7 @@ 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';
@@ -22,11 +24,10 @@ import { isatty } from 'node:tty';
22
24
  import EventEmitter from 'node:events';
23
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
 
@@ -2405,14 +2406,7 @@ async function groupFilesByEnv(files) {
2405
2406
  const code = await promises$1.readFile(filepath, "utf-8");
2406
2407
  // 1. Check for control comments in the file
2407
2408
  let env = code.match(/@(?:vitest|jest)-environment\s+([\w-]+)\b/)?.[1];
2408
- // 2. Check for globals
2409
- if (!env) {
2410
- for (const [glob, target] of project.config.environmentMatchGlobs || []) if (pm.isMatch(filepath, glob, { cwd: project.config.root })) {
2411
- env = target;
2412
- break;
2413
- }
2414
- }
2415
- // 3. Fallback to global env
2409
+ // 2. Fallback to global env
2416
2410
  env ||= project.config.environment || "node";
2417
2411
  const transformMode = getTransformMode(project.config.testTransformMode, filepath);
2418
2412
  let envOptionsJson = code.match(/@(?:vitest|jest)-environment-options\s+(.+)/)?.[1];
@@ -2450,14 +2444,6 @@ function createMethodsRPC(project, options = {}) {
2450
2444
  resolveSnapshotPath(testPath) {
2451
2445
  return ctx.snapshot.resolvePath(testPath, { config: project.serializedConfig });
2452
2446
  },
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
2447
  async fetch(id, transformMode) {
2462
2448
  const result = await project.vitenode.fetchResult(id, transformMode).catch(handleRollupError);
2463
2449
  const code = result.code;
@@ -3299,11 +3285,7 @@ function getDefaultPoolName(project) {
3299
3285
  if (project.config.browser.enabled) return "browser";
3300
3286
  return project.config.pool;
3301
3287
  }
3302
- function getFilePoolName(project, file) {
3303
- 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");
3305
- if (pm.isMatch(file, glob, { cwd: project.config.root })) return pool;
3306
- }
3288
+ function getFilePoolName(project) {
3307
3289
  return getDefaultPoolName(project);
3308
3290
  }
3309
3291
  function createPool(ctx) {
@@ -3652,12 +3634,19 @@ function resolveConfig$1(vitest, options, viteConfig) {
3652
3634
  resolved.deps.web.transformGlobPattern ??= [];
3653
3635
  resolved.setupFiles = toArray(resolved.setupFiles || []).map((file) => resolvePath(file, resolved.root));
3654
3636
  resolved.globalSetup = toArray(resolved.globalSetup || []).map((file) => resolvePath(file, resolved.root));
3655
- // override original exclude array for cases where user re-uses same object in test.exclude
3637
+ // Add hard-coded default coverage exclusions. These cannot be overidden by user config.
3638
+ // Override original exclude array for cases where user re-uses same object in test.exclude.
3656
3639
  resolved.coverage.exclude = [
3657
3640
  ...resolved.coverage.exclude,
3658
3641
  ...resolved.setupFiles.map((file) => `${resolved.coverage.allowExternal ? "**/" : ""}${relative(resolved.root, file)}`),
3659
- ...resolved.include
3660
- ];
3642
+ ...resolved.include,
3643
+ resolved.config && slash$1(resolved.config),
3644
+ ...configFiles,
3645
+ ...workspacesFiles,
3646
+ "**/virtual:*",
3647
+ "**/__x00__*",
3648
+ "**/node_modules/**"
3649
+ ].filter((pattern) => pattern != null);
3661
3650
  resolved.forceRerunTriggers = [...resolved.forceRerunTriggers, ...resolved.setupFiles];
3662
3651
  resolved.server ??= {};
3663
3652
  resolved.server.deps ??= {};
@@ -3770,11 +3759,6 @@ function resolveConfig$1(vitest, options, viteConfig) {
3770
3759
  // if passed down from the CLI and it's relative, resolve relative to CWD
3771
3760
  resolved.workspace = typeof options.workspace === "string" && options.workspace[0] === "." ? resolve$1(process.cwd(), options.workspace) : resolvePath(resolved.workspace, resolved.root);
3772
3761
  if (!builtinPools.includes(resolved.pool)) resolved.pool = resolvePath(resolved.pool, resolved.root);
3773
- if (resolved.poolMatchGlobs) logger.deprecate("`poolMatchGlobs` is deprecated. Use `test.projects` to define different configurations instead.");
3774
- resolved.poolMatchGlobs = (resolved.poolMatchGlobs || []).map(([glob, pool]) => {
3775
- if (!builtinPools.includes(pool)) pool = resolvePath(pool, resolved.root);
3776
- return [glob, pool];
3777
- });
3778
3762
  if (mode === "benchmark") {
3779
3763
  resolved.benchmark = {
3780
3764
  ...benchmarkConfigDefaults,
@@ -3872,8 +3856,6 @@ function resolveConfig$1(vitest, options, viteConfig) {
3872
3856
  ...configDefaults.typecheck,
3873
3857
  ...resolved.typecheck
3874
3858
  };
3875
- if (resolved.environmentMatchGlobs) logger.deprecate("\"environmentMatchGlobs\" is deprecated. Use `test.projects` to define different configurations instead.");
3876
- resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve$1(resolved.root, i[0]), i[1]]);
3877
3859
  resolved.typecheck ??= {};
3878
3860
  resolved.typecheck.enabled ??= false;
3879
3861
  if (resolved.typecheck.enabled) logger.console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
@@ -3962,6 +3944,7 @@ class BaseCoverageProvider {
3962
3944
  name;
3963
3945
  version;
3964
3946
  options;
3947
+ globCache = /* @__PURE__ */ new Map();
3965
3948
  coverageFiles = /* @__PURE__ */ new Map();
3966
3949
  pendingPromises = [];
3967
3950
  coverageFilesDirectory;
@@ -3989,6 +3972,44 @@ Update your dependencies and make sure the versions match.`));
3989
3972
  const tempDirectory = `.tmp${shard ? `-${shard.index}-${shard.count}` : ""}`;
3990
3973
  this.coverageFilesDirectory = resolve$1(this.options.reportsDirectory, tempDirectory);
3991
3974
  }
3975
+ /**
3976
+ * Check if file matches `coverage.include` but not `coverage.exclude`
3977
+ */
3978
+ isIncluded(_filename) {
3979
+ const filename = slash(_filename);
3980
+ const cacheHit = this.globCache.get(filename);
3981
+ if (cacheHit !== void 0) return cacheHit;
3982
+ // File outside project root with default allowExternal
3983
+ if (this.options.allowExternal === false && !filename.startsWith(this.ctx.config.root)) {
3984
+ this.globCache.set(filename, false);
3985
+ return false;
3986
+ }
3987
+ const options = {
3988
+ contains: true,
3989
+ dot: true,
3990
+ cwd: this.ctx.config.root,
3991
+ ignore: this.options.exclude
3992
+ };
3993
+ // By default `coverage.include` matches all files, except "coverage.exclude"
3994
+ const glob = this.options.include || "**";
3995
+ const included = pm.isMatch(filename, glob, options) && existsSync(cleanUrl(filename));
3996
+ this.globCache.set(filename, included);
3997
+ return included;
3998
+ }
3999
+ async getUntestedFiles(testedFiles) {
4000
+ if (this.options.include == null) return [];
4001
+ let includedFiles = await glob(this.options.include, {
4002
+ cwd: this.ctx.config.root,
4003
+ ignore: [...this.options.exclude, ...testedFiles.map((file) => slash(file))],
4004
+ absolute: true,
4005
+ dot: true,
4006
+ onlyFiles: true
4007
+ });
4008
+ // Run again through picomatch as tinyglobby's exclude pattern is different ({ "exclude": ["math"] } should ignore "src/math.ts")
4009
+ includedFiles = includedFiles.filter((file) => this.isIncluded(file));
4010
+ if (this.ctx.config.changed) includedFiles = (this.ctx.config.related || []).filter((file) => includedFiles.includes(file));
4011
+ return includedFiles.map((file) => slash(path.resolve(this.ctx.config.root, file)));
4012
+ }
3992
4013
  createCoverageMap() {
3993
4014
  throw new Error("BaseReporter's createCoverageMap was not overwritten");
3994
4015
  }
@@ -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';
@@ -7,8 +7,6 @@ import { assert, should } from 'chai';
7
7
 
8
8
  const assertType = function assertType() {};
9
9
 
10
- // TODO: deprecate <reference types="vitest" /> in favor of `<reference types="vitest/config" />`
11
-
12
10
  var VitestIndex = /*#__PURE__*/Object.freeze({
13
11
  __proto__: null,
14
12
  afterAll: afterAll,
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
3
3
  import * as pathe from 'pathe';
4
4
  import c from 'tinyrainbow';
5
- import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName } from './index.VByaPkjc.js';
5
+ import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName } from './index.a-yuRg2G.js';
6
6
  import { stripVTControlCharacters } from 'node:util';
7
7
  import { notNullish } from '@vitest/utils';
8
8