vitest 3.0.7 → 3.0.9

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 (66) hide show
  1. package/dist/browser.d.ts +14 -43
  2. package/dist/browser.js +4 -4
  3. package/dist/chunks/{base.BgUWWWYp.js → base.DV59CbtV.js} +2 -2
  4. package/dist/chunks/{benchmark.Cdu9hjj4.js → benchmark.DL72EVN-.js} +1 -1
  5. package/dist/chunks/{benchmark.CFFwLv-O.d.ts → benchmark.d.BwvBVTda.d.ts} +11 -11
  6. package/dist/chunks/{cac.87F_onld.js → cac.CeVHgzve.js} +30 -6
  7. package/dist/chunks/{cli-api.BZbq1zTX.js → cli-api.Ckwz_xSb.js} +21 -23
  8. package/dist/chunks/config.d.DevWltVl.d.ts +218 -0
  9. package/dist/chunks/{constants.fzPh7AOq.js → constants.DTYd6dNH.js} +1 -1
  10. package/dist/chunks/{coverage.DnNIv-kJ.js → coverage.A3sS5-Wm.js} +1 -29
  11. package/dist/chunks/coverage.d.S9RMNXIe.d.ts +35 -0
  12. package/dist/chunks/{resolveConfig.BbcK25zb.js → coverage.gV8doR2Y.js} +500 -131
  13. package/dist/chunks/{creator.2CFRE1Yx.js → creator.BsBnpTzI.js} +1 -1
  14. package/dist/chunks/defaults.C2Ndd9wx.js +119 -0
  15. package/dist/chunks/env.D4Lgay0q.js +8 -0
  16. package/dist/chunks/environment.d.C8UItCbf.d.ts +170 -0
  17. package/dist/chunks/{execute.Bhwls1-Z.js → execute.eDH0aFFd.js} +4 -4
  18. package/dist/chunks/global.d.Cg2sEPIm.d.ts +127 -0
  19. package/dist/chunks/{globals.BCtI_nQG.js → globals.BEpDe-k3.js} +5 -5
  20. package/dist/chunks/{index.C1f-_gvH.js → index.B8tIoLPT.js} +8 -3
  21. package/dist/chunks/{index.B8haHJlQ.js → index.D7Ny8f_s.js} +2 -2
  22. package/dist/chunks/{index.BmFFzXX_.js → index.uXkkC4xl.js} +1 -2
  23. package/dist/chunks/{mocker.cRtM890J.d.ts → mocker.d.BE_2ls6u.d.ts} +6 -6
  24. package/dist/chunks/reporters.d.CqBhtcTq.d.ts +3006 -0
  25. package/dist/chunks/{runBaseTests.9XCQcSZC.js → runBaseTests.BVrL_ow3.js} +9 -9
  26. package/dist/chunks/{setup-common.wObu9a36.js → setup-common.CPvtqi8q.js} +25 -2
  27. package/dist/chunks/{suite.qtkXWc6R.d.ts → suite.d.FvehnV49.d.ts} +1 -1
  28. package/dist/chunks/{typechecker.cZ0LjdSi.js → typechecker.BlF3eHsb.js} +2 -7
  29. package/dist/chunks/{vi.DT3m61kS.js → vi.nSCvwQ7l.js} +4 -4
  30. package/dist/chunks/vite.d.BUZTGxQ3.d.ts +11 -0
  31. package/dist/chunks/{vm.6kNys9FN.js → vm.jEFQDlX_.js} +1 -1
  32. package/dist/chunks/{worker.DaAIyCKm.d.ts → worker.d.C58isfFm.d.ts} +62 -62
  33. package/dist/chunks/{worker.B2JXutr8.d.ts → worker.d.CSFlSYJg.d.ts} +2 -2
  34. package/dist/cli.js +2 -2
  35. package/dist/config.d.ts +48 -45
  36. package/dist/config.js +6 -123
  37. package/dist/coverage.d.ts +82 -79
  38. package/dist/coverage.js +19 -469
  39. package/dist/environments.d.ts +11 -11
  40. package/dist/execute.d.ts +109 -109
  41. package/dist/execute.js +1 -1
  42. package/dist/index.d.ts +414 -412
  43. package/dist/index.js +4 -4
  44. package/dist/node.d.ts +51 -48
  45. package/dist/node.js +13 -10
  46. package/dist/reporters.d.ts +7 -4
  47. package/dist/reporters.js +3 -2
  48. package/dist/runners.d.ts +28 -28
  49. package/dist/runners.js +3 -4
  50. package/dist/snapshot.d.ts +2 -2
  51. package/dist/suite.d.ts +2 -2
  52. package/dist/suite.js +1 -1
  53. package/dist/workers/forks.js +2 -2
  54. package/dist/workers/runVmTests.js +9 -9
  55. package/dist/workers/threads.js +2 -2
  56. package/dist/workers/vmForks.js +2 -2
  57. package/dist/workers/vmThreads.js +2 -2
  58. package/dist/workers.d.ts +13 -13
  59. package/dist/workers.js +3 -3
  60. package/package.json +12 -12
  61. package/dist/chunks/config.BRtC-JeT.d.ts +0 -215
  62. package/dist/chunks/environment.d8YfPkTm.d.ts +0 -173
  63. package/dist/chunks/global.CnI8_G5V.d.ts +0 -133
  64. package/dist/chunks/reporters.QZ837uWx.d.ts +0 -3051
  65. package/dist/chunks/spy.Cf_4R5Oe.js +0 -22
  66. package/dist/chunks/vite.vM3UZq1q.d.ts +0 -11
package/dist/browser.d.ts CHANGED
@@ -1,60 +1,31 @@
1
- import { b as CoverageModuleLoader, c as CoverageProvider } from './chunks/reporters.QZ837uWx.js';
2
- import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.BRtC-JeT.js';
3
- import * as spy$1 from '@vitest/spy';
1
+ import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.DevWltVl.js';
2
+ import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.S9RMNXIe.js';
4
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
5
4
  import { VitestExecutor } from './execute.js';
6
5
  export { collectTests, processError, startTests } from '@vitest/runner';
7
- import './chunks/environment.d8YfPkTm.js';
8
- import '@vitest/utils';
9
- import 'node:stream';
10
- import 'vite';
11
- import '@vitest/utils/source-map';
6
+ import * as spy from '@vitest/spy';
7
+ export { spy as SpyModule };
12
8
  import '@vitest/pretty-format';
13
9
  import '@vitest/snapshot';
14
- import 'vite-node';
15
- import 'chai';
16
- import './chunks/benchmark.CFFwLv-O.js';
17
- import '@vitest/runner/utils';
18
- import 'tinybench';
19
- import '@vitest/snapshot/manager';
20
- import 'node:fs';
21
10
  import '@vitest/snapshot/environment';
22
11
  import 'vite-node/client';
23
- import './chunks/worker.DaAIyCKm.js';
12
+ import 'vite-node';
13
+ import './chunks/worker.d.C58isfFm.js';
14
+ import './chunks/environment.d.C8UItCbf.js';
24
15
  import 'node:vm';
25
16
  import '@vitest/mocker';
26
- import './chunks/mocker.cRtM890J.js';
27
-
28
- function _mergeNamespaces(n, m) {
29
- m.forEach(function (e) {
30
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
31
- if (k !== 'default' && !(k in n)) {
32
- var d = Object.getOwnPropertyDescriptor(e, k);
33
- Object.defineProperty(n, k, d.get ? d : {
34
- enumerable: true,
35
- get: function () { return e[k]; }
36
- });
37
- }
38
- });
39
- });
40
- return Object.freeze(n);
41
- }
42
-
43
- var spy = /*#__PURE__*/_mergeNamespaces({
44
- __proto__: null
45
- }, [spy$1]);
17
+ import './chunks/mocker.d.BE_2ls6u.js';
46
18
 
47
- declare function getCoverageProvider(options: SerializedCoverageConfig | undefined, loader: CoverageModuleLoader): Promise<CoverageProvider | null>;
48
- declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: CoverageModuleLoader, runtimeOptions: {
49
- isolate: boolean;
19
+ declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
20
+ isolate: boolean
50
21
  }): Promise<unknown>;
51
- declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: CoverageModuleLoader): Promise<unknown>;
52
- declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: CoverageModuleLoader, runtimeOptions: {
53
- isolate: boolean;
22
+ declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader): Promise<unknown>;
23
+ declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
24
+ isolate: boolean
54
25
  }): Promise<unknown>;
55
26
 
56
27
  declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
57
28
  declare function loadDiffConfig(config: SerializedConfig, executor: VitestExecutor): Promise<SerializedDiffOptions | undefined>;
58
29
  declare function loadSnapshotSerializers(config: SerializedConfig, executor: VitestExecutor): Promise<void>;
59
30
 
60
- export { spy as SpyModule, getCoverageProvider, loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
31
+ export { loadDiffConfig, loadSnapshotSerializers, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, takeCoverageInsideWorker };
package/dist/browser.js CHANGED
@@ -1,8 +1,8 @@
1
- export { g as getCoverageProvider, s as startCoverageInsideWorker, a as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/coverage.DnNIv-kJ.js';
2
- export { s as SpyModule } from './chunks/spy.Cf_4R5Oe.js';
3
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv } from './chunks/setup-common.wObu9a36.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.CPvtqi8q.js';
4
2
  export { collectTests, processError, startTests } from '@vitest/runner';
5
- import '@vitest/spy';
3
+ import * as spy from '@vitest/spy';
4
+ export { spy as SpyModule };
5
+ import './chunks/coverage.A3sS5-Wm.js';
6
6
  import '@vitest/snapshot';
7
7
  import '@vitest/utils';
8
8
  import './chunks/run-once.2ogXb3JV.js';
@@ -1,5 +1,5 @@
1
1
  import { ModuleCacheMap } from 'vite-node/client';
2
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Bhwls1-Z.js';
2
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.eDH0aFFd.js';
3
3
  import { p as provideWorkerState } from './utils.C8RiOc4B.js';
4
4
 
5
5
  let _viteNode;
@@ -28,7 +28,7 @@ async function runBaseTests(method, state) {
28
28
  ));
29
29
  const [executor, { run }] = await Promise.all([
30
30
  startViteNode({ state, requestStubs: getDefaultRequestStubs() }),
31
- import('./runBaseTests.9XCQcSZC.js')
31
+ import('./runBaseTests.BVrL_ow3.js')
32
32
  ]);
33
33
  const fileSpecs = ctx.files.map(
34
34
  (f) => typeof f === "string" ? { filepath: f, testLocations: void 0 } : f
@@ -34,7 +34,7 @@ function createBenchmark(fn) {
34
34
  return benchmark;
35
35
  }
36
36
  function formatName(name) {
37
- return typeof name === "string" ? name : name instanceof Function ? name.name || "<anonymous>" : String(name);
37
+ return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
38
38
  }
39
39
 
40
40
  export { getBenchOptions as a, bench as b, getBenchFn as g };
@@ -3,22 +3,22 @@ import { ChainableFunction } from '@vitest/runner/utils';
3
3
  import { TaskResult, Bench, Options } from 'tinybench';
4
4
 
5
5
  interface Benchmark extends Test {
6
- meta: {
7
- benchmark: true;
8
- result?: TaskResult;
9
- };
6
+ meta: {
7
+ benchmark: true
8
+ result?: TaskResult
9
+ };
10
10
  }
11
11
  interface BenchmarkResult extends TaskResult {
12
- name: string;
13
- rank: number;
14
- sampleCount: number;
15
- median: number;
12
+ name: string;
13
+ rank: number;
14
+ sampleCount: number;
15
+ median: number;
16
16
  }
17
17
  type BenchFunction = (this: Bench) => Promise<void> | void;
18
- type ChainableBenchmarkAPI = ChainableFunction<'skip' | 'only' | 'todo', (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
18
+ type ChainableBenchmarkAPI = ChainableFunction<"skip" | "only" | "todo", (name: string | Function, fn?: BenchFunction, options?: Options) => void>;
19
19
  type BenchmarkAPI = ChainableBenchmarkAPI & {
20
- skipIf: (condition: any) => ChainableBenchmarkAPI;
21
- runIf: (condition: any) => ChainableBenchmarkAPI;
20
+ skipIf: (condition: any) => ChainableBenchmarkAPI
21
+ runIf: (condition: any) => ChainableBenchmarkAPI
22
22
  };
23
23
 
24
24
  export type { BenchmarkResult as B, BenchFunction as a, Benchmark as b, BenchmarkAPI as c };
@@ -2,7 +2,7 @@ import { toArray } from '@vitest/utils';
2
2
  import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
4
  import c from 'tinyrainbow';
5
- import { d as defaultPort, a as defaultBrowserPort } from './constants.fzPh7AOq.js';
5
+ import { a as defaultPort, d as defaultBrowserPort } from './constants.DTYd6dNH.js';
6
6
 
7
7
  function toArr(any) {
8
8
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -618,7 +618,7 @@ class CAC extends EventEmitter {
618
618
 
619
619
  const cac = (name = "") => new CAC(name);
620
620
 
621
- var version = "3.0.7";
621
+ var version = "3.0.9";
622
622
 
623
623
  const apiConfig = (port) => ({
624
624
  port: {
@@ -1398,6 +1398,7 @@ function addCommand(cli, name, option) {
1398
1398
  `Expected a single value for option "${command}", received [${received}]`
1399
1399
  );
1400
1400
  }
1401
+ value = removeQuotes(value);
1401
1402
  if (option.transform) {
1402
1403
  return option.transform(value);
1403
1404
  }
@@ -1502,8 +1503,31 @@ function createCLI(options = {}) {
1502
1503
  cli.command("[...filters]", void 0, options).action((filters, options2) => start("test", filters, options2));
1503
1504
  return cli;
1504
1505
  }
1506
+ function removeQuotes(str) {
1507
+ if (typeof str !== "string") {
1508
+ if (Array.isArray(str)) {
1509
+ return str.map(removeQuotes);
1510
+ }
1511
+ return str;
1512
+ }
1513
+ if (str.startsWith('"') && str.endsWith('"')) {
1514
+ return str.slice(1, -1);
1515
+ }
1516
+ if (str.startsWith(`'`) && str.endsWith(`'`)) {
1517
+ return str.slice(1, -1);
1518
+ }
1519
+ return str;
1520
+ }
1521
+ function splitArgv(argv) {
1522
+ const reg = /(['"])(?:(?!\1).)+\1/g;
1523
+ argv = argv.replace(reg, (match) => match.replace(/\s/g, "\0"));
1524
+ return argv.split(" ").map((arg) => {
1525
+ arg = arg.replace(/\0/g, " ");
1526
+ return removeQuotes(arg);
1527
+ });
1528
+ }
1505
1529
  function parseCLI(argv, config = {}) {
1506
- const arrayArgs = typeof argv === "string" ? argv.split(" ") : argv;
1530
+ const arrayArgs = typeof argv === "string" ? splitArgv(argv) : argv;
1507
1531
  if (arrayArgs[0] !== "vitest") {
1508
1532
  throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
1509
1533
  }
@@ -1567,7 +1591,7 @@ async function start(mode, cliFilters, options) {
1567
1591
  } catch {
1568
1592
  }
1569
1593
  try {
1570
- const { startVitest } = await import('./cli-api.BZbq1zTX.js').then(function (n) { return n.f; });
1594
+ const { startVitest } = await import('./cli-api.Ckwz_xSb.js').then(function (n) { return n.f; });
1571
1595
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1572
1596
  if (!ctx.shouldKeepServer()) {
1573
1597
  await ctx.exit();
@@ -1589,7 +1613,7 @@ async function init(project) {
1589
1613
  console.error(new Error('Only the "browser" project is supported. Use "vitest init browser" to create a new project.'));
1590
1614
  process.exit(1);
1591
1615
  }
1592
- const { create } = await import('./creator.2CFRE1Yx.js');
1616
+ const { create } = await import('./creator.BsBnpTzI.js');
1593
1617
  await create();
1594
1618
  }
1595
1619
  async function collect(mode, cliFilters, options) {
@@ -1598,7 +1622,7 @@ async function collect(mode, cliFilters, options) {
1598
1622
  } catch {
1599
1623
  }
1600
1624
  try {
1601
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BZbq1zTX.js').then(function (n) { return n.f; });
1625
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.Ckwz_xSb.js').then(function (n) { return n.f; });
1602
1626
  const ctx = await prepareVitest(mode, {
1603
1627
  ...normalizeCliOptions(cliFilters, options),
1604
1628
  watch: false,
@@ -1,19 +1,19 @@
1
1
  import { promises, existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
2
2
  import { relative, extname, normalize, dirname, resolve, join, basename, isAbsolute } from 'pathe';
3
- import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.DnNIv-kJ.js';
3
+ import { C as CoverageProviderMap } from './coverage.A3sS5-Wm.js';
4
4
  import p, { resolve as resolve$1 } from 'node:path';
5
5
  import { noop, isPrimitive, createDefer, highlight, toArray, deepMerge, nanoid, slash, deepClone, notNullish } from '@vitest/utils';
6
6
  import { f as findUp, p as prompt } from './index.DBIGubLC.js';
7
7
  import * as vite from 'vite';
8
8
  import { searchForWorkspaceRoot, version, createServer, mergeConfig } from 'vite';
9
- import { A as API_PATH, c as configFiles, a as defaultBrowserPort, w as workspacesFiles, d as defaultPort } from './constants.fzPh7AOq.js';
9
+ import { A as API_PATH, c as configFiles, d as defaultBrowserPort, w as workspacesFiles, a as defaultPort } from './constants.DTYd6dNH.js';
10
10
  import { generateFileHash, createFileTask, limitConcurrency, hasFailed, getTasks, getTests } from '@vitest/runner/utils';
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.87F_onld.js';
14
+ import { v as version$1 } from './cac.CeVHgzve.js';
15
15
  import { c as createBirpc } from './index.68735LiX.js';
16
- import { p as parse, s as stringify, g as printError, h as generateCodeFrame, b as BenchmarkReportsMap, R as ReportersMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.C1f-_gvH.js';
16
+ import { p as parse, s as stringify, g as printError, h as generateCodeFrame, b as BenchmarkReportsMap, R as ReportersMap, i as BlobReporter, r as readBlobs, H as HangingProcessReporter } from './index.B8tIoLPT.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,19 +28,21 @@ import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
28
28
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
29
29
  import crypto from 'node:crypto';
30
30
  import { distDir, rootDir } from '../path.js';
31
- import { R as RandomSequencer, i as isPackageExists, h as hash, V as VitestCache, e as configDefaults, g as getFilePoolName, f as isBrowserEnabled, m as mm, a as resolveConfig, j as groupBy, w as wildcardPatternToRegExp, k as createPool, b as resolveApiServerConfig, s as stdout } from './resolveConfig.BbcK25zb.js';
32
- import { i as isTTY, b as isWindows, c as convertTasksToEvents } from './typechecker.cZ0LjdSi.js';
31
+ import { R as RandomSequencer, i as isPackageExists, h as hash, V as VitestCache, g as getFilePoolName, d as isBrowserEnabled, m as mm, r as resolveConfig, e as groupBy, w as wildcardPatternToRegExp, f as getCoverageProvider, j as createPool, a as resolveApiServerConfig, s as stdout } from './coverage.gV8doR2Y.js';
32
+ import { c as convertTasksToEvents } from './typechecker.BlF3eHsb.js';
33
33
  import { Console } from 'node:console';
34
34
  import c from 'tinyrainbow';
35
35
  import { a as formatProjectName, w as withLabel, d as divider } from './utils.bLM2atbD.js';
36
36
  import { createRequire } from 'node:module';
37
37
  import url from 'node:url';
38
+ import { i as isTTY, a as isWindows } from './env.D4Lgay0q.js';
38
39
  import { rm } from 'node:fs/promises';
39
40
  import nodeos__default, { tmpdir } from 'node:os';
40
41
  import require$$0$4, { posix } from 'path';
41
42
  import require$$0$5 from 'fs';
42
43
  import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
43
44
  import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
45
+ import { c as configDefaults } from './defaults.C2Ndd9wx.js';
44
46
  import MagicString from 'magic-string';
45
47
  import assert$1 from 'node:assert';
46
48
  import { serializeError } from '@vitest/utils/error';
@@ -9067,7 +9069,10 @@ function serializeConfig(config, coreConfig, viteConfig) {
9067
9069
  screenshotFailures: browser.screenshotFailures,
9068
9070
  locators: {
9069
9071
  testIdAttribute: browser.locators.testIdAttribute
9070
- }
9072
+ },
9073
+ providerOptions: browser.provider === "playwright" ? {
9074
+ actionTimeout: browser.providerOptions?.context?.actionTimeout
9075
+ } : {}
9071
9076
  };
9072
9077
  })(config.browser),
9073
9078
  standalone: config.standalone,
@@ -9954,17 +9959,6 @@ function deleteDefineConfig(viteConfig) {
9954
9959
  }
9955
9960
  return defines;
9956
9961
  }
9957
- function hijackVitePluginInject(viteConfig) {
9958
- const processEnvPlugin = viteConfig.plugins.find(
9959
- (p) => p.name === "vite:client-inject"
9960
- );
9961
- if (processEnvPlugin) {
9962
- const originalTransform = processEnvPlugin.transform;
9963
- processEnvPlugin.transform = function transform(code, id, options) {
9964
- return originalTransform.call(this, code, id, { ...options, ssr: true });
9965
- };
9966
- }
9967
- }
9968
9962
  function resolveFsAllow(projectRoot, rootConfigFile) {
9969
9963
  if (!rootConfigFile) {
9970
9964
  return [searchForWorkspaceRoot(projectRoot), rootDir];
@@ -10136,6 +10130,10 @@ function WorkspaceVitestPlugin(project, options) {
10136
10130
  const resolveOptions = getDefaultResolveOptions();
10137
10131
  const config = {
10138
10132
  root,
10133
+ define: {
10134
+ // disable replacing `process.env.NODE_ENV` with static string by vite:client-inject
10135
+ "process.env.NODE_ENV": "process.env.NODE_ENV"
10136
+ },
10139
10137
  resolve: {
10140
10138
  ...resolveOptions,
10141
10139
  alias: testConfig.alias
@@ -10200,9 +10198,6 @@ function WorkspaceVitestPlugin(project, options) {
10200
10198
  config.customLogger = silenceImportViteIgnoreWarning(config.customLogger);
10201
10199
  return config;
10202
10200
  },
10203
- configResolved(viteConfig) {
10204
- hijackVitePluginInject(viteConfig);
10205
- },
10206
10201
  async configureServer(server) {
10207
10202
  const options2 = deepMerge({}, configDefaults, server.config.test || {});
10208
10203
  await project._configureServer(options2, server);
@@ -12117,7 +12112,7 @@ async function resolveBrowserWorkspace(vitest, names, resolvedProjects) {
12117
12112
  }
12118
12113
  if (project.config.browser.providerOptions) {
12119
12114
  vitest.logger.warn(
12120
- withLabel("yellow", "Vitest", `"providerOptions"${originalName ? ` in "${originalName}" project` : ""} is ignored because it's overriden by the configs. To hide this warning, remove the "providerOptions" property from the browser configuration.`)
12115
+ withLabel("yellow", "Vitest", `"providerOptions"${originalName ? ` in "${originalName}" project` : ""} is ignored because it's overridden by the configs. To hide this warning, remove the "providerOptions" property from the browser configuration.`)
12121
12116
  );
12122
12117
  }
12123
12118
  filteredInstances.forEach((config, index) => {
@@ -13348,6 +13343,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
13348
13343
  const resolveOptions = getDefaultResolveOptions();
13349
13344
  const config = {
13350
13345
  root: viteConfig.test?.root || options.root,
13346
+ define: {
13347
+ // disable replacing `process.env.NODE_ENV` with static string by vite:client-inject
13348
+ "process.env.NODE_ENV": "process.env.NODE_ENV"
13349
+ },
13351
13350
  esbuild: viteConfig.esbuild === false ? false : {
13352
13351
  // Lowest target Vitest supports is Node18
13353
13352
  target: viteConfig.esbuild?.target || "node18",
@@ -13465,7 +13464,6 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
13465
13464
  if (!options.watch) {
13466
13465
  viteConfig.server.watch = null;
13467
13466
  }
13468
- hijackVitePluginInject(viteConfig);
13469
13467
  Object.defineProperty(viteConfig, "_vitest", {
13470
13468
  value: options,
13471
13469
  enumerable: false,
@@ -0,0 +1,218 @@
1
+ import { PrettyFormatOptions } from '@vitest/pretty-format';
2
+ import { SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
3
+ import { SnapshotUpdateState } from '@vitest/snapshot';
4
+ import { SnapshotEnvironment } from '@vitest/snapshot/environment';
5
+ import { SerializedDiffOptions } from '@vitest/utils/diff';
6
+
7
+ /**
8
+ * Names of clock methods that may be faked by install.
9
+ */
10
+ type FakeMethod =
11
+ | "setTimeout"
12
+ | "clearTimeout"
13
+ | "setImmediate"
14
+ | "clearImmediate"
15
+ | "setInterval"
16
+ | "clearInterval"
17
+ | "Date"
18
+ | "nextTick"
19
+ | "hrtime"
20
+ | "requestAnimationFrame"
21
+ | "cancelAnimationFrame"
22
+ | "requestIdleCallback"
23
+ | "cancelIdleCallback"
24
+ | "performance"
25
+ | "queueMicrotask";
26
+
27
+ interface FakeTimerInstallOpts {
28
+ /**
29
+ * Installs fake timers with the specified unix epoch (default: 0)
30
+ */
31
+ now?: number | Date | undefined;
32
+
33
+ /**
34
+ * An array with names of global methods and APIs to fake.
35
+ * For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()`
36
+ * @default everything available globally except `nextTick`
37
+ */
38
+ toFake?: FakeMethod[] | undefined;
39
+
40
+ /**
41
+ * The maximum number of timers that will be run when calling runAll()
42
+ * @default 10000
43
+ */
44
+ loopLimit?: number | undefined;
45
+
46
+ /**
47
+ * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
48
+ * 20ms for every 20ms change in the real system time) (default: false)
49
+ */
50
+ shouldAdvanceTime?: boolean | undefined;
51
+
52
+ /**
53
+ * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
54
+ * in the real system time (default: 20)
55
+ */
56
+ advanceTimeDelta?: number | undefined;
57
+
58
+ /**
59
+ * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
60
+ * @default true
61
+ */
62
+ shouldClearNativeTimers?: boolean | undefined;
63
+
64
+ /**
65
+ * Don't throw error when asked to fake timers that are not present.
66
+ * @default false
67
+ */
68
+ ignoreMissingTimers?: boolean | undefined;
69
+ }
70
+
71
+ /**
72
+ * Config that tests have access to.
73
+ */
74
+ interface SerializedConfig {
75
+ name: string | undefined;
76
+ globals: boolean;
77
+ base: string | undefined;
78
+ snapshotEnvironment?: string;
79
+ disableConsoleIntercept: boolean | undefined;
80
+ runner: string | undefined;
81
+ isolate: boolean;
82
+ mode: "test" | "benchmark";
83
+ bail: number | undefined;
84
+ environmentOptions?: Record<string, any>;
85
+ root: string;
86
+ setupFiles: string[];
87
+ passWithNoTests: boolean;
88
+ testNamePattern: RegExp | undefined;
89
+ allowOnly: boolean;
90
+ testTimeout: number;
91
+ hookTimeout: number;
92
+ clearMocks: boolean;
93
+ mockReset: boolean;
94
+ restoreMocks: boolean;
95
+ unstubGlobals: boolean;
96
+ unstubEnvs: boolean;
97
+ fakeTimers: FakeTimerInstallOpts;
98
+ maxConcurrency: number;
99
+ defines: Record<string, any>;
100
+ expect: {
101
+ requireAssertions?: boolean
102
+ poll?: {
103
+ timeout?: number
104
+ interval?: number
105
+ }
106
+ };
107
+ printConsoleTrace: boolean | undefined;
108
+ sequence: {
109
+ shuffle?: boolean
110
+ concurrent?: boolean
111
+ seed: number
112
+ hooks: SequenceHooks
113
+ setupFiles: SequenceSetupFiles
114
+ };
115
+ poolOptions: {
116
+ forks: {
117
+ singleFork: boolean
118
+ isolate: boolean
119
+ }
120
+ threads: {
121
+ singleThread: boolean
122
+ isolate: boolean
123
+ }
124
+ vmThreads: {
125
+ singleThread: boolean
126
+ }
127
+ vmForks: {
128
+ singleFork: boolean
129
+ }
130
+ };
131
+ deps: {
132
+ web: {
133
+ transformAssets?: boolean
134
+ transformCss?: boolean
135
+ transformGlobPattern?: RegExp | RegExp[]
136
+ }
137
+ optimizer: {
138
+ web: {
139
+ enabled: boolean
140
+ }
141
+ ssr: {
142
+ enabled: boolean
143
+ }
144
+ }
145
+ interopDefault: boolean | undefined
146
+ moduleDirectories: string[] | undefined
147
+ };
148
+ snapshotOptions: {
149
+ updateSnapshot: SnapshotUpdateState
150
+ expand: boolean | undefined
151
+ snapshotFormat: PrettyFormatOptions | undefined
152
+ /**
153
+ * only exists for tests, not available in the main process
154
+ */
155
+ snapshotEnvironment: SnapshotEnvironment
156
+ };
157
+ pool: string;
158
+ snapshotSerializers: string[];
159
+ chaiConfig: {
160
+ includeStack?: boolean
161
+ showDiff?: boolean
162
+ truncateThreshold?: number
163
+ } | undefined;
164
+ diff: string | SerializedDiffOptions | undefined;
165
+ retry: number;
166
+ includeTaskLocation: boolean | undefined;
167
+ inspect: boolean | string | undefined;
168
+ inspectBrk: boolean | string | undefined;
169
+ inspector: {
170
+ enabled?: boolean
171
+ port?: number
172
+ host?: string
173
+ waitForDebugger?: boolean
174
+ };
175
+ watch: boolean;
176
+ env: Record<string, any>;
177
+ browser: {
178
+ name: string
179
+ headless: boolean
180
+ isolate: boolean
181
+ fileParallelism: boolean
182
+ ui: boolean
183
+ viewport: {
184
+ width: number
185
+ height: number
186
+ }
187
+ locators: {
188
+ testIdAttribute: string
189
+ }
190
+ screenshotFailures: boolean
191
+ providerOptions: {
192
+ actionTimeout?: number
193
+ }
194
+ };
195
+ standalone: boolean;
196
+ logHeapUsage: boolean | undefined;
197
+ coverage: SerializedCoverageConfig;
198
+ benchmark?: {
199
+ includeSamples: boolean
200
+ };
201
+ }
202
+ interface SerializedCoverageConfig {
203
+ provider: "istanbul" | "v8" | "custom" | undefined;
204
+ reportsDirectory: string;
205
+ htmlReporter: {
206
+ subdir: string | undefined
207
+ } | undefined;
208
+ enabled: boolean;
209
+ customProviderModule: string | undefined;
210
+ }
211
+ type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookTimeout" | "clearMocks" | "mockReset" | "restoreMocks" | "fakeTimers" | "maxConcurrency" | "expect" | "printConsoleTrace"> & {
212
+ sequence?: {
213
+ hooks?: SequenceHooks
214
+ }
215
+ };
216
+ type RuntimeOptions = Partial<RuntimeConfig>;
217
+
218
+ export type { FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedCoverageConfig as S, SerializedConfig as a, RuntimeConfig as b };
@@ -43,4 +43,4 @@ const globalApis = [
43
43
  "onTestFailed"
44
44
  ];
45
45
 
46
- export { API_PATH as A, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
46
+ export { API_PATH as A, defaultPort as a, defaultInspectPort as b, configFiles as c, defaultBrowserPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
@@ -36,33 +36,5 @@ async function resolveCoverageProviderModule(options, loader) {
36
36
  }
37
37
  return customProviderModule.default;
38
38
  }
39
- async function getCoverageProvider(options, loader) {
40
- const coverageModule = await resolveCoverageProviderModule(options, loader);
41
- if (coverageModule) {
42
- return coverageModule.getProvider();
43
- }
44
- return null;
45
- }
46
- async function startCoverageInsideWorker(options, loader, runtimeOptions) {
47
- const coverageModule = await resolveCoverageProviderModule(options, loader);
48
- if (coverageModule) {
49
- return coverageModule.startCoverage?.(runtimeOptions);
50
- }
51
- return null;
52
- }
53
- async function takeCoverageInsideWorker(options, loader) {
54
- const coverageModule = await resolveCoverageProviderModule(options, loader);
55
- if (coverageModule) {
56
- return coverageModule.takeCoverage?.({ moduleExecutionInfo: loader.moduleExecutionInfo });
57
- }
58
- return null;
59
- }
60
- async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
61
- const coverageModule = await resolveCoverageProviderModule(options, loader);
62
- if (coverageModule) {
63
- return coverageModule.stopCoverage?.(runtimeOptions);
64
- }
65
- return null;
66
- }
67
39
 
68
- export { CoverageProviderMap as C, stopCoverageInsideWorker as a, getCoverageProvider as g, startCoverageInsideWorker as s, takeCoverageInsideWorker as t };
40
+ export { CoverageProviderMap as C, resolveCoverageProviderModule as r };
@@ -0,0 +1,35 @@
1
+ import { ModuleExecutionInfo } from 'vite-node/client';
2
+
3
+ interface RuntimeCoverageModuleLoader {
4
+ executeId: (id: string) => Promise<{
5
+ default: RuntimeCoverageProviderModule
6
+ }>;
7
+ isBrowser?: boolean;
8
+ moduleExecutionInfo?: ModuleExecutionInfo;
9
+ }
10
+ interface RuntimeCoverageProviderModule {
11
+ /**
12
+ * Factory for creating a new coverage provider
13
+ */
14
+ getProvider: () => any;
15
+ /**
16
+ * Executed before tests are run in the worker thread.
17
+ */
18
+ startCoverage?: (runtimeOptions: {
19
+ isolate: boolean
20
+ }) => unknown | Promise<unknown>;
21
+ /**
22
+ * Executed on after each run in the worker thread. Possible to return a payload passed to the provider
23
+ */
24
+ takeCoverage?: (runtimeOptions?: {
25
+ moduleExecutionInfo?: ModuleExecutionInfo
26
+ }) => unknown | Promise<unknown>;
27
+ /**
28
+ * Executed after all tests have been run in the worker thread.
29
+ */
30
+ stopCoverage?: (runtimeOptions: {
31
+ isolate: boolean
32
+ }) => unknown | Promise<unknown>;
33
+ }
34
+
35
+ export type { RuntimeCoverageModuleLoader as R, RuntimeCoverageProviderModule as a };