vitest 4.0.0-beta.2 → 4.0.0-beta.4

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 (60) hide show
  1. package/dist/browser.d.ts +6 -6
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.Bj3pWTr1.js → base.BaCDDRPG.js} +2 -2
  4. package/dist/chunks/{benchmark.d.BwvBVTda.d.ts → benchmark.d.DAaHLpsq.d.ts} +4 -4
  5. package/dist/chunks/{browser.d.DP0ACFkh.d.ts → browser.d.BRP8scJf.d.ts} +5 -5
  6. package/dist/chunks/{cac.CVVvMokL.js → cac.CY0IAxC4.js} +19 -18
  7. package/dist/chunks/{cli-api.BUkNuHvl.js → cli-api.B8xRY9Zt.js} +45 -71
  8. package/dist/chunks/{config.d.HJdfX-8k.d.ts → config.d.DZo8c7fw.d.ts} +58 -58
  9. package/dist/chunks/{console.CtFJOzRO.js → console.DoJHFxmj.js} +3 -3
  10. package/dist/chunks/{constants.DnKduX2e.js → constants.CXzqaLmq.js} +1 -4
  11. package/dist/chunks/{coverage.BjMqihzx.js → coverage.C84l9G-M.js} +92 -64
  12. package/dist/chunks/{coverage.d.S9RMNXIe.d.ts → coverage.d.CNYjU4GF.d.ts} +4 -4
  13. package/dist/chunks/{creator.GK6I-cL4.js → creator.yfA2ExGt.js} +68 -7
  14. package/dist/chunks/{environment.d.CUq4cUgQ.d.ts → environment.d.Bhm9oc0v.d.ts} +1 -1
  15. package/dist/chunks/{execute.B7h3T_Hc.js → execute.Dt-pCVcL.js} +1 -1
  16. package/dist/chunks/{global.d.CVbXEflG.d.ts → global.d.DAhT2emn.d.ts} +2 -2
  17. package/dist/chunks/{globals.Cxal6MLI.js → globals.Dgo-vS5G.js} +3 -3
  18. package/dist/chunks/{index.B521nVV-.js → index.Bgo3tNWt.js} +23 -4
  19. package/dist/chunks/{index.a-yuRg2G.js → index.Bz6b0Ib7.js} +5 -4
  20. package/dist/chunks/{index.D-VkfKhf.js → index.CtUvr1c8.js} +2 -2
  21. package/dist/chunks/{index.BWf_gE5n.js → index.D1_MsKEt.js} +1 -1
  22. package/dist/chunks/{index.CJvUWPky.js → index.D3SKT3tv.js} +1 -1
  23. package/dist/chunks/{plugin.d.NmsBIHuT.d.ts → plugin.d.CLhMcYdD.d.ts} +1 -1
  24. package/dist/chunks/{reporters.d.BbsDWlO9.d.ts → reporters.d.DWg40D2B.d.ts} +200 -110
  25. package/dist/chunks/{rpc.CsFtxqeq.js → rpc.jnQO9F8a.js} +4 -8
  26. package/dist/chunks/{runBaseTests.BC7ZIH5L.js → runBaseTests.DBVVLMSb.js} +7 -7
  27. package/dist/chunks/{setup-common.D7ZqXFx-.js → setup-common.Ebx5x0eP.js} +1 -1
  28. package/dist/chunks/{suite.d.FvehnV49.d.ts → suite.d.BJWk38HB.d.ts} +1 -1
  29. package/dist/chunks/{typechecker.CVytUJuF.js → typechecker.CMNPqJOo.js} +3 -3
  30. package/dist/chunks/{utils.CAioKnHs.js → utils.CcGm2cd1.js} +1 -1
  31. package/dist/chunks/{vi.bdSIJ99Y.js → vi.CA0EPI9Y.js} +11 -11
  32. package/dist/chunks/{vm.BThCzidc.js → vm.BUnLJt_P.js} +11 -3
  33. package/dist/chunks/{worker.d.CVn8WGlF.d.ts → worker.d.C-1AbnVe.d.ts} +1 -1
  34. package/dist/chunks/{worker.d.COAQvn4k.d.ts → worker.d.zjyR34Pb.d.ts} +18 -9
  35. package/dist/cli.js +4 -4
  36. package/dist/config.d.ts +44 -44
  37. package/dist/config.js +1 -1
  38. package/dist/coverage.d.ts +20 -18
  39. package/dist/coverage.js +4 -4
  40. package/dist/environments.d.ts +9 -9
  41. package/dist/execute.d.ts +7 -7
  42. package/dist/execute.js +1 -1
  43. package/dist/index.d.ts +28 -23
  44. package/dist/index.js +2 -2
  45. package/dist/node.d.ts +23 -21
  46. package/dist/node.js +10 -10
  47. package/dist/reporters.d.ts +7 -7
  48. package/dist/reporters.js +3 -3
  49. package/dist/runners.d.ts +1 -1
  50. package/dist/runners.js +4 -4
  51. package/dist/suite.d.ts +2 -2
  52. package/dist/worker.js +11 -5
  53. package/dist/workers/forks.js +3 -3
  54. package/dist/workers/runVmTests.js +6 -6
  55. package/dist/workers/threads.js +3 -3
  56. package/dist/workers/vmForks.js +4 -4
  57. package/dist/workers/vmThreads.js +4 -4
  58. package/dist/workers.d.ts +4 -4
  59. package/dist/workers.js +7 -7
  60. package/package.json +19 -19
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.HJdfX-8k.js';
2
- import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.S9RMNXIe.js';
1
+ import { S as SerializedCoverageConfig, a as SerializedConfig } from './chunks/config.d.DZo8c7fw.js';
2
+ import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.CNYjU4GF.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
4
  import { VitestExecutor } from './execute.js';
5
5
  export { collectTests, processError, startTests } from '@vitest/runner';
@@ -11,18 +11,18 @@ import '@vitest/pretty-format';
11
11
  import '@vitest/snapshot';
12
12
  import 'vite-node/client';
13
13
  import 'vite-node';
14
- import './chunks/worker.d.COAQvn4k.js';
15
- import './chunks/environment.d.CUq4cUgQ.js';
14
+ import './chunks/worker.d.zjyR34Pb.js';
15
+ import './chunks/environment.d.Bhm9oc0v.js';
16
16
  import 'node:vm';
17
17
  import '@vitest/mocker';
18
18
  import './chunks/mocker.d.BE_2ls6u.js';
19
19
 
20
20
  declare function startCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
21
- isolate: boolean
21
+ isolate: boolean;
22
22
  }): Promise<unknown>;
23
23
  declare function takeCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader): Promise<unknown>;
24
24
  declare function stopCoverageInsideWorker(options: SerializedCoverageConfig | undefined, loader: RuntimeCoverageModuleLoader, runtimeOptions: {
25
- isolate: boolean
25
+ isolate: boolean;
26
26
  }): Promise<unknown>;
27
27
 
28
28
  declare function setupCommonEnv(config: SerializedConfig): Promise<void>;
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.D7ZqXFx-.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.Ebx5x0eP.js';
2
2
  export { collectTests, processError, startTests } from '@vitest/runner';
3
3
  import * as spy from '@vitest/spy';
4
4
  export { spy as SpyModule };
@@ -1,5 +1,5 @@
1
1
  import { ModuleCacheMap } from 'vite-node/client';
2
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.B7h3T_Hc.js';
2
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Dt-pCVcL.js';
3
3
  import { p as provideWorkerState } from './utils.XdZDrNZV.js';
4
4
 
5
5
  let _viteNode;
@@ -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.BC7ZIH5L.js')]);
27
+ }), import('./runBaseTests.DBVVLMSb.js')]);
28
28
  const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
29
29
  filepath: f,
30
30
  testLocations: void 0
@@ -4,8 +4,8 @@ import { TaskResult, Bench, Options } from 'tinybench';
4
4
 
5
5
  interface Benchmark extends Test {
6
6
  meta: {
7
- benchmark: true
8
- result?: TaskResult
7
+ benchmark: true;
8
+ result?: TaskResult;
9
9
  };
10
10
  }
11
11
  interface BenchmarkResult extends TaskResult {
@@ -17,8 +17,8 @@ interface BenchmarkResult extends TaskResult {
17
17
  type BenchFunction = (this: Bench) => Promise<void> | void;
18
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 };
@@ -1,11 +1,11 @@
1
- import { T as TestExecutionMethod } from './worker.d.COAQvn4k.js';
1
+ import { T as TestExecutionMethod } from './worker.d.zjyR34Pb.js';
2
2
 
3
3
  type SerializedTestSpecification = [project: {
4
- name: string | undefined
5
- root: string
4
+ name: string | undefined;
5
+ root: string;
6
6
  }, file: string, options: {
7
- pool: string
8
- testLines?: number[] | undefined
7
+ pool: string;
8
+ testLines?: number[] | undefined;
9
9
  }];
10
10
 
11
11
  interface BrowserTesterOptions {
@@ -2,8 +2,8 @@ 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 { a as defaultPort, d as defaultBrowserPort } from './constants.DnKduX2e.js';
6
- import { R as ReportersMap } from './index.a-yuRg2G.js';
5
+ import { a as defaultPort, d as defaultBrowserPort } from './constants.CXzqaLmq.js';
6
+ import { R as ReportersMap } from './index.Bz6b0Ib7.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 = "4.0.0-beta.2";
622
+ var version = "4.0.0-beta.4";
623
623
 
624
624
  const apiConfig = (port) => ({
625
625
  port: {
@@ -836,11 +836,6 @@ const cliOptionsConfig = {
836
836
  description: "Override Vite mode (default: `test` or `benchmark`)",
837
837
  argument: "<name>"
838
838
  },
839
- workspace: {
840
- description: "[deprecated] Path to a workspace configuration file",
841
- argument: "<path>",
842
- normalize: true
843
- },
844
839
  isolate: { description: "Run every test file in isolation. To disable isolation, use `--no-isolate` (default: `true`)" },
845
840
  globals: { description: "Inject apis globally" },
846
841
  dom: { description: "Mock browser API with happy-dom" },
@@ -891,7 +886,8 @@ const cliOptionsConfig = {
891
886
  screenshotFailures: null,
892
887
  locators: null,
893
888
  testerHtmlPath: null,
894
- instances: null
889
+ instances: null,
890
+ expect: null
895
891
  }
896
892
  },
897
893
  pool: {
@@ -1183,7 +1179,7 @@ const cliOptionsConfig = {
1183
1179
  description: "Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly. This is only available in vite version 6.1.0 and above. (default: `bundle`)",
1184
1180
  argument: "<loader>"
1185
1181
  },
1186
- standalone: { description: "Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)" },
1182
+ standalone: { description: "Start Vitest without running tests. Tests will be running only on change. This option is ignored when CLI file filters are passed. (default: `false`)" },
1187
1183
  mergeReports: {
1188
1184
  description: "Path to a blob reports directory. If this options is used, Vitest won't run any tests, it will only report previously recorded tests",
1189
1185
  argument: "[path]",
@@ -1239,11 +1235,16 @@ const benchCliOptionsConfig = {
1239
1235
  }
1240
1236
  };
1241
1237
  const collectCliOptionsConfig = {
1238
+ ...cliOptionsConfig,
1242
1239
  json: {
1243
1240
  description: "Print collected tests as JSON or write to a file (Default: false)",
1244
1241
  argument: "[true/path]"
1245
1242
  },
1246
- filesOnly: { description: "Print only test files with out the test cases" }
1243
+ filesOnly: { description: "Print only test files with out the test cases" },
1244
+ changed: {
1245
+ description: "Print only tests that are affected by the changed files (default: `false`)",
1246
+ argument: "[since]"
1247
+ }
1247
1248
  };
1248
1249
 
1249
1250
  function addCommand(cli, name, option) {
@@ -1397,11 +1398,11 @@ async function start(mode, cliFilters, options) {
1397
1398
  process.title = "node (vitest)";
1398
1399
  } catch {}
1399
1400
  try {
1400
- const { startVitest } = await import('./cli-api.BUkNuHvl.js').then(function (n) { return n.f; });
1401
+ const { startVitest } = await import('./cli-api.B8xRY9Zt.js').then(function (n) { return n.f; });
1401
1402
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1402
1403
  if (!ctx.shouldKeepServer()) await ctx.exit();
1403
1404
  } catch (e) {
1404
- const { errorBanner } = await import('./index.a-yuRg2G.js').then(function (n) { return n.u; });
1405
+ const { errorBanner } = await import('./index.Bz6b0Ib7.js').then(function (n) { return n.u; });
1405
1406
  console.error(`\n${errorBanner("Startup Error")}`);
1406
1407
  console.error(e);
1407
1408
  console.error("\n\n");
@@ -1411,10 +1412,10 @@ async function start(mode, cliFilters, options) {
1411
1412
  }
1412
1413
  async function init(project) {
1413
1414
  if (project !== "browser") {
1414
- console.error(new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
1415
+ console.error(/* @__PURE__ */ new Error("Only the \"browser\" project is supported. Use \"vitest init browser\" to create a new project."));
1415
1416
  process.exit(1);
1416
1417
  }
1417
- const { create } = await import('./creator.GK6I-cL4.js');
1418
+ const { create } = await import('./creator.yfA2ExGt.js');
1418
1419
  await create();
1419
1420
  }
1420
1421
  async function collect(mode, cliFilters, options) {
@@ -1422,12 +1423,12 @@ async function collect(mode, cliFilters, options) {
1422
1423
  process.title = "node (vitest)";
1423
1424
  } catch {}
1424
1425
  try {
1425
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BUkNuHvl.js').then(function (n) { return n.f; });
1426
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.B8xRY9Zt.js').then(function (n) { return n.f; });
1426
1427
  const ctx = await prepareVitest(mode, {
1427
1428
  ...normalizeCliOptions(cliFilters, options),
1428
1429
  watch: false,
1429
1430
  run: true
1430
- });
1431
+ }, void 0, void 0, cliFilters);
1431
1432
  if (!options.filesOnly) {
1432
1433
  const { testModules: tests, unhandledErrors: errors } = await ctx.collect(cliFilters.map(normalize));
1433
1434
  if (errors.length) {
@@ -1444,7 +1445,7 @@ async function collect(mode, cliFilters, options) {
1444
1445
  }
1445
1446
  await ctx.close();
1446
1447
  } catch (e) {
1447
- const { errorBanner } = await import('./index.a-yuRg2G.js').then(function (n) { return n.u; });
1448
+ const { errorBanner } = await import('./index.Bz6b0Ib7.js').then(function (n) { return n.u; });
1448
1449
  console.error(`\n${errorBanner("Collect Error")}`);
1449
1450
  console.error(e);
1450
1451
  console.error("\n\n");
@@ -6,14 +6,14 @@ import { noop, isPrimitive, createDefer, slash, highlight, toArray, deepMerge, n
6
6
  import { f as findUp, p as prompt } from './index.X0nbfr6-.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, d as defaultBrowserPort, w as workspacesFiles, a as defaultPort } from './constants.DnKduX2e.js';
9
+ import { A as API_PATH, c as configFiles, d as defaultBrowserPort, a as defaultPort } from './constants.CXzqaLmq.js';
10
10
  import { generateFileHash, limitConcurrency, createFileTask, 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.CVVvMokL.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.a-yuRg2G.js';
14
+ import { v as version$1 } from './cac.CY0IAxC4.js';
15
+ import { c as createBirpc } from './index.Bgo3tNWt.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.Bz6b0Ib7.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.BjMqihzx.js';
32
- import { c as convertTasksToEvents } from './typechecker.CVytUJuF.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.C84l9G-M.js';
32
+ import { c as convertTasksToEvents } from './typechecker.CMNPqJOo.js';
33
33
  import { Console } from 'node:console';
34
34
  import c from 'tinyrainbow';
35
35
  import { createRequire } from 'node:module';
@@ -43,7 +43,7 @@ import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
43
43
  import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
44
44
  import { c as configDefaults } from './defaults.CXFFjsi8.js';
45
45
  import MagicString from 'magic-string';
46
- import { a as BenchmarkReportsMap } from './index.CJvUWPky.js';
46
+ import { a as BenchmarkReportsMap } from './index.D3SKT3tv.js';
47
47
  import assert$1 from 'node:assert';
48
48
  import { serializeError } from '@vitest/utils/error';
49
49
  import readline from 'node:readline';
@@ -4717,9 +4717,11 @@ function requireWebsocketServer () {
4717
4717
  return;
4718
4718
  }
4719
4719
 
4720
- if (version !== 8 && version !== 13) {
4720
+ if (version !== 13 && version !== 8) {
4721
4721
  const message = 'Missing or invalid Sec-WebSocket-Version header';
4722
- abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
4722
+ abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
4723
+ 'Sec-WebSocket-Version': '13, 8'
4724
+ });
4723
4725
  return;
4724
4726
  }
4725
4727
 
@@ -4987,16 +4989,24 @@ function requireWebsocketServer () {
4987
4989
  * @param {Duplex} socket The socket of the upgrade request
4988
4990
  * @param {Number} code The HTTP response status code
4989
4991
  * @param {String} message The HTTP response body
4992
+ * @param {Object} [headers] The HTTP response headers
4990
4993
  * @private
4991
4994
  */
4992
- function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
4995
+ function abortHandshakeOrEmitwsClientError(
4996
+ server,
4997
+ req,
4998
+ socket,
4999
+ code,
5000
+ message,
5001
+ headers
5002
+ ) {
4993
5003
  if (server.listenerCount('wsClientError')) {
4994
5004
  const err = new Error(message);
4995
5005
  Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
4996
5006
 
4997
5007
  server.emit('wsClientError', err, socket, req);
4998
5008
  } else {
4999
- abortHandshake(socket, code, message);
5009
+ abortHandshake(socket, code, message, headers);
5000
5010
  }
5001
5011
  }
5002
5012
  return websocketServer;
@@ -5169,13 +5179,12 @@ function setup(ctx, _server) {
5169
5179
  ],
5170
5180
  serialize: (data) => stringify(data, stringifyReplace),
5171
5181
  deserialize: parse,
5172
- onTimeoutError(functionName) {
5173
- throw new Error(`[vitest-api]: Timeout calling "${functionName}"`);
5174
- }
5182
+ timeout: -1
5175
5183
  });
5176
5184
  clients.set(ws, rpc);
5177
5185
  ws.on("close", () => {
5178
5186
  clients.delete(ws);
5187
+ rpc.$close(/* @__PURE__ */ new Error("[vitest-api]: Pending methods while closing rpc"));
5179
5188
  });
5180
5189
  }
5181
5190
  ctx.reporters.push(new WebSocketReporter(ctx, wss, clients));
@@ -5257,7 +5266,7 @@ class BrowserSessions {
5257
5266
  // this promise only waits for the WS connection with the orhcestrator to be established
5258
5267
  const defer = createDefer();
5259
5268
  const timeout = setTimeout(() => {
5260
- defer.reject(new Error(`Failed to connect to the browser session "${sessionId}" [${project.name}] within the timeout.`));
5269
+ defer.reject(/* @__PURE__ */ new Error(`Failed to connect to the browser session "${sessionId}" [${project.name}] within the timeout.`));
5261
5270
  }, project.vitest.config.browser.connectTimeout ?? 6e4).unref();
5262
5271
  this.sessions.set(sessionId, {
5263
5272
  project,
@@ -5746,10 +5755,7 @@ function serializeConfig(config, coreConfig, viteConfig) {
5746
5755
  snapshotOptions: {
5747
5756
  snapshotEnvironment: void 0,
5748
5757
  updateSnapshot: coreConfig.snapshotOptions.updateSnapshot,
5749
- snapshotFormat: {
5750
- ...coreConfig.snapshotOptions.snapshotFormat,
5751
- compareKeys: void 0
5752
- },
5758
+ snapshotFormat: { ...coreConfig.snapshotOptions.snapshotFormat },
5753
5759
  expand: config.snapshotOptions.expand ?? coreConfig.snapshotOptions.expand
5754
5760
  },
5755
5761
  sequence: {
@@ -5949,7 +5955,7 @@ function silenceImportViteIgnoreWarning(logger) {
5949
5955
 
5950
5956
  const cssLangs = "\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)";
5951
5957
  const cssLangRE = new RegExp(cssLangs);
5952
- const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
5958
+ const cssModuleRE = /* @__PURE__ */ new RegExp(`\\.module${cssLangs}`);
5953
5959
  const cssInlineRE = /[?&]inline(?:&|$)/;
5954
5960
  function isCSS(id) {
5955
5961
  return cssLangRE.test(id);
@@ -7434,7 +7440,7 @@ async function resolveProjects(vitest, cliOptions, workspaceConfigPath, projects
7434
7440
  const fileProjects = [...configFiles, ...nonConfigDirectories];
7435
7441
  const concurrent = limitConcurrency(nodeos__default.availableParallelism?.() || nodeos__default.cpus().length || 5);
7436
7442
  projectConfigs.forEach((options, index) => {
7437
- const configRoot = workspaceConfigPath ? dirname(workspaceConfigPath) : vitest.config.root;
7443
+ const configRoot = vitest.config.root;
7438
7444
  // if extends a config file, resolve the file path
7439
7445
  const configFile = typeof options.extends === "string" ? resolve(configRoot, options.extends) : options.extends === true ? vitest.vite.config.configFile || false : false;
7440
7446
  // if `root` is configured, resolve it relative to the workspace file or vite root (like other options)
@@ -7614,8 +7620,7 @@ async function resolveTestProjectConfigs(vitest, workspaceConfigPath, projectsDe
7614
7620
  if (!isDynamicPattern(stringOption)) {
7615
7621
  const file = resolve(vitest.config.root, stringOption);
7616
7622
  if (!existsSync(file)) {
7617
- const relativeWorkspaceConfigPath = workspaceConfigPath ? relative(vitest.config.root, workspaceConfigPath) : void 0;
7618
- const note = workspaceConfigPath ? `Workspace config file "${relativeWorkspaceConfigPath}"` : "Projects definition";
7623
+ const note = "Projects definition";
7619
7624
  throw new Error(`${note} references a non-existing file or a directory: ${file}`);
7620
7625
  }
7621
7626
  const stats = await promises.stat(file);
@@ -8242,6 +8247,11 @@ class StateManager {
8242
8247
  reportedTasksMap = /* @__PURE__ */ new WeakMap();
8243
8248
  blobs;
8244
8249
  onUnhandledError;
8250
+ /** @internal */
8251
+ _data = {
8252
+ browserLastPort: defaultBrowserPort,
8253
+ timeoutIncreased: false
8254
+ };
8245
8255
  constructor(options) {
8246
8256
  this.onUnhandledError = options.onUnhandledError;
8247
8257
  }
@@ -9166,12 +9176,6 @@ class Vitest {
9166
9176
  /** @internal */ closingPromise;
9167
9177
  /** @internal */ isCancelling = false;
9168
9178
  /** @internal */ coreWorkspaceProject;
9169
- /**
9170
- * @internal
9171
- * @deprecated
9172
- */
9173
- resolvedProjects = [];
9174
- /** @internal */ _browserLastPort = defaultBrowserPort;
9175
9179
  /** @internal */ _browserSessions = new BrowserSessions();
9176
9180
  /** @internal */ _cliOptions = {};
9177
9181
  /** @internal */ reporters = [];
@@ -9188,7 +9192,6 @@ class Vitest {
9188
9192
  _state;
9189
9193
  _cache;
9190
9194
  _snapshot;
9191
- _workspaceConfigPath;
9192
9195
  constructor(mode, cliOptions, options = {}) {
9193
9196
  this.mode = mode;
9194
9197
  this._cliOptions = cliOptions;
@@ -9260,13 +9263,10 @@ class Vitest {
9260
9263
  this.watcher.unregisterWatcher();
9261
9264
  clearTimeout(this._rerunTimer);
9262
9265
  this.restartsCount += 1;
9263
- this._browserLastPort = defaultBrowserPort;
9264
9266
  this.pool?.close?.();
9265
9267
  this.pool = void 0;
9266
9268
  this.closingPromise = void 0;
9267
9269
  this.projects = [];
9268
- this.resolvedProjects = [];
9269
- this._workspaceConfigPath = void 0;
9270
9270
  this.coverageProvider = void 0;
9271
9271
  this.runningPromise = void 0;
9272
9272
  this.coreWorkspaceProject = void 0;
@@ -9304,7 +9304,7 @@ class Vitest {
9304
9304
  // since we set `server.hmr: false`, Vite does not auto restart itself
9305
9305
  server.watcher.on("change", async (file) => {
9306
9306
  file = normalize(file);
9307
- const isConfig = file === server.config.configFile || this.projects.some((p) => p.vite.config.configFile === file) || file === this._workspaceConfigPath;
9307
+ const isConfig = file === server.config.configFile || this.projects.some((p) => p.vite.config.configFile === file);
9308
9308
  if (isConfig) {
9309
9309
  await Promise.all(this._onRestartListeners.map((fn) => fn("config")));
9310
9310
  this.report("onServerRestart", "config");
@@ -9318,7 +9318,6 @@ class Vitest {
9318
9318
  await this.cache.results.readFromCache();
9319
9319
  } catch {}
9320
9320
  const projects = await this.resolveProjects(this._cliOptions);
9321
- this.resolvedProjects = projects;
9322
9321
  this.projects = projects;
9323
9322
  await Promise.all(projects.flatMap((project) => {
9324
9323
  const hooks = project.vite.config.getSortedPluginHooks("configureVitest");
@@ -9402,41 +9401,15 @@ class Vitest {
9402
9401
  import(moduleId) {
9403
9402
  return this.runner.executeId(moduleId);
9404
9403
  }
9405
- async resolveWorkspaceConfigPath() {
9406
- if (typeof this.config.workspace === "string") return this.config.workspace;
9407
- const configDir = this.vite.config.configFile ? dirname(this.vite.config.configFile) : this.config.root;
9408
- const rootFiles = await promises.readdir(configDir);
9409
- const workspaceConfigName = workspacesFiles.find((configFile) => {
9410
- return rootFiles.includes(configFile);
9411
- });
9412
- if (!workspaceConfigName) return void 0;
9413
- return join(configDir, workspaceConfigName);
9414
- }
9415
9404
  async resolveProjects(cliOptions) {
9416
9405
  const names = /* @__PURE__ */ new Set();
9417
- if (this.config.projects) {
9418
- if (typeof this.config.workspace !== "undefined") this.logger.warn("Both `test.projects` and `test.workspace` are defined. Ignoring the `test.workspace` option.");
9419
- return resolveProjects(this, cliOptions, void 0, this.config.projects, names);
9420
- }
9421
- if (Array.isArray(this.config.workspace)) {
9422
- 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`.");
9423
- return resolveProjects(this, cliOptions, void 0, this.config.workspace, names);
9424
- }
9425
- const workspaceConfigPath = await this.resolveWorkspaceConfigPath();
9426
- this._workspaceConfigPath = workspaceConfigPath;
9427
- // user doesn't have a workspace config, return default project
9428
- if (!workspaceConfigPath) {
9429
- // user can filter projects with --project flag, `getDefaultTestProject`
9430
- // returns the project only if it matches the filter
9431
- const project = getDefaultTestProject(this);
9432
- if (!project) return [];
9433
- return resolveBrowserProjects(this, new Set([project.name]), [project]);
9434
- }
9435
- const configFile = this.vite.config.configFile ? resolve(this.vite.config.root, this.vite.config.configFile) : "the root config file";
9436
- 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.`);
9437
- const workspaceModule = await this.import(workspaceConfigPath);
9438
- if (!workspaceModule.default || !Array.isArray(workspaceModule.default)) throw new TypeError(`Workspace config file "${workspaceConfigPath}" must export a default array of project paths.`);
9439
- return resolveProjects(this, cliOptions, workspaceConfigPath, workspaceModule.default, names);
9406
+ if (this.config.projects) return resolveProjects(this, cliOptions, void 0, this.config.projects, names);
9407
+ if ("workspace" in this.config) throw new Error("The `test.workspace` option was removed in Vitest 4. Please, migrate to `test.projects` instead. See https://vitest.dev/guide/projects for examples.");
9408
+ // user can filter projects with --project flag, `getDefaultTestProject`
9409
+ // returns the project only if it matches the filter
9410
+ const project = getDefaultTestProject(this);
9411
+ if (!project) return [];
9412
+ return resolveBrowserProjects(this, new Set([project.name]), [project]);
9440
9413
  }
9441
9414
  /**
9442
9415
  * Glob test files in every project and create a TestSpecification for each file and pool.
@@ -10448,7 +10421,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout) {
10448
10421
  const watchFilter = new WatchFilter("Input filename pattern", stdin, stdout);
10449
10422
  const filter = await watchFilter.filter(async (str) => {
10450
10423
  const files = await ctx.globTestFiles([str]);
10451
- return files.map((file) => relative(ctx.config.root, file[1]));
10424
+ return files.map((file) => relative(ctx.config.root, file[1])).filter((file, index, all) => all.indexOf(file) === index);
10452
10425
  });
10453
10426
  on();
10454
10427
  if (typeof filter === "undefined") return;
@@ -10486,7 +10459,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout) {
10486
10459
  */
10487
10460
  async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, vitestOptions) {
10488
10461
  const root = resolve(options.root || process.cwd());
10489
- const ctx = await prepareVitest(mode, options, viteOverrides, vitestOptions);
10462
+ const ctx = await prepareVitest(mode, options, viteOverrides, vitestOptions, cliFilters);
10490
10463
  if (mode === "test" && ctx.config.coverage.enabled) {
10491
10464
  const provider = ctx.config.coverage.provider || "v8";
10492
10465
  const requiredPackages = CoverageProviderMap[provider];
@@ -10532,11 +10505,12 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
10532
10505
  await ctx.close();
10533
10506
  return ctx;
10534
10507
  }
10535
- async function prepareVitest(mode, options = {}, viteOverrides, vitestOptions) {
10508
+ async function prepareVitest(mode, options = {}, viteOverrides, vitestOptions, cliFilters) {
10536
10509
  process.env.TEST = "true";
10537
10510
  process.env.VITEST = "true";
10538
10511
  process.env.NODE_ENV ??= "test";
10539
10512
  if (options.run) options.watch = false;
10513
+ if (options.standalone && (cliFilters?.length || 0) > 0) options.standalone = false;
10540
10514
  // this shouldn't affect _application root_ that can be changed inside config
10541
10515
  const root = resolve(options.root || process.cwd());
10542
10516
  const ctx = await createVitest(mode, options, viteOverrides, vitestOptions);