vitest 4.1.0-beta.6 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/browser.js +3 -3
  2. package/dist/chunks/{base.C98-6XAz.js → base.C9_VThnT.js} +9 -9
  3. package/dist/chunks/{cac.Vtz91O0H.js → cac.CHfKU_gf.js} +18 -8
  4. package/dist/chunks/{cli-api.Bqj5xGy5.js → cli-api.BUXBO6jS.js} +195 -59
  5. package/dist/chunks/{coverage.DUqi2f6q.js → coverage.CJ2HXVIG.js} +17 -11
  6. package/dist/chunks/{coverage.D_JHT54q.js → coverage.CTzCuANN.js} +4 -1
  7. package/dist/chunks/{defaults.BlJmGxXD.js → defaults.CdU2lD-q.js} +2 -2
  8. package/dist/chunks/{globals.DA6L6i5h.js → globals.8mibwXRO.js} +2 -2
  9. package/dist/chunks/{index.5lgR0kvt.js → index.6q6giCZO.js} +2 -2
  10. package/dist/chunks/{index.CHsi7RlU.js → index.CEzQDJGb.js} +1 -1
  11. package/dist/chunks/{index.EY6TCHpo.js → index.DC7d2Pf8.js} +2 -2
  12. package/dist/chunks/{index.DpkD7Zj4.js → index.DXMFO5MJ.js} +426 -393
  13. package/dist/chunks/{index.IcAjQV7n.js → index.Dkvtd-Ku.js} +1 -1
  14. package/dist/chunks/{init-forks.BwPkXyLk.js → init-forks.B4YYSIj4.js} +1 -1
  15. package/dist/chunks/{init-threads.BuSVu8Ns.js → init-threads.Bd2Hsaex.js} +1 -1
  16. package/dist/chunks/{init.Borgldul.js → init.BVxhC4nR.js} +3 -3
  17. package/dist/chunks/{native.mV0-490A.js → native.DPzPHdi5.js} +1 -1
  18. package/dist/chunks/{nativeModuleMocker.wQT5wU7r.js → nativeModuleMocker.Dd1Q1VIw.js} +2 -2
  19. package/dist/chunks/{plugin.d.pmonRL8Y.d.ts → plugin.d.Dx0ozo6e.d.ts} +1 -1
  20. package/dist/chunks/{reporters.d.CRDGoPlb.d.ts → reporters.d.CZ5E0GCT.d.ts} +64 -29
  21. package/dist/chunks/{setup-common.z3ZfZiWN.js → setup-common.CB31_KSV.js} +2 -2
  22. package/dist/chunks/{startVitestModuleRunner.BdSYEN5x.js → startVitestModuleRunner.C3FXk5Gv.js} +4 -4
  23. package/dist/chunks/{test.PnxXDGpZ.js → test.CBQUpOM3.js} +4 -1
  24. package/dist/chunks/{traces.CCmnQaNT.js → traces.DT5aQ62U.js} +1 -1
  25. package/dist/chunks/{vm.V092iA4c.js → vm.DId8XBJa.js} +2 -2
  26. package/dist/cli.js +3 -3
  27. package/dist/config.cjs +1 -1
  28. package/dist/config.d.ts +3 -3
  29. package/dist/config.js +1 -1
  30. package/dist/coverage.d.ts +4 -4
  31. package/dist/coverage.js +3 -3
  32. package/dist/environments.js +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +2 -2
  35. package/dist/module-evaluator.js +2 -2
  36. package/dist/node.d.ts +3 -3
  37. package/dist/node.js +11 -11
  38. package/dist/nodejs-worker-loader.js +1 -1
  39. package/dist/reporters.d.ts +1 -1
  40. package/dist/reporters.js +4 -4
  41. package/dist/runners.d.ts +2 -1
  42. package/dist/runners.js +1 -1
  43. package/dist/runtime.js +3 -3
  44. package/dist/worker.js +10 -10
  45. package/dist/workers/forks.js +11 -11
  46. package/dist/workers/runVmTests.js +5 -5
  47. package/dist/workers/threads.js +11 -11
  48. package/dist/workers/vmForks.js +6 -6
  49. package/dist/workers/vmThreads.js +6 -6
  50. package/optional-runtime-types.d.ts +6 -0
  51. package/package.json +21 -18
  52. package/dist/chunks/git.Bm2pzPAa.js +0 -71
package/dist/browser.js CHANGED
@@ -1,5 +1,5 @@
1
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.z3ZfZiWN.js';
2
- export { T as Traces } from './chunks/traces.CCmnQaNT.js';
1
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.CB31_KSV.js';
2
+ export { T as Traces } from './chunks/traces.DT5aQ62U.js';
3
3
  export { collectTests, startTests } from '@vitest/runner';
4
4
  import * as spyModule from '@vitest/spy';
5
5
  export { spyModule as SpyModule };
@@ -8,7 +8,7 @@ export { processError } from '@vitest/utils/error';
8
8
  export { getType } from '@vitest/utils/helpers';
9
9
  export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
10
10
  export { getSafeTimers, setSafeTimers } from '@vitest/utils/timers';
11
- import './chunks/coverage.D_JHT54q.js';
11
+ import './chunks/coverage.CTzCuANN.js';
12
12
  import '@vitest/snapshot';
13
13
  import './chunks/utils.BX5Fg8C4.js';
14
14
 
@@ -1,22 +1,22 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import * as spyModule from '@vitest/spy';
3
- import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.5lgR0kvt.js';
4
- import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.Borgldul.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.6q6giCZO.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.BVxhC4nR.js';
5
5
  import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
6
- import { T as Traces } from './traces.CCmnQaNT.js';
6
+ import { T as Traces } from './traces.DT5aQ62U.js';
7
7
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
8
- import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.BdSYEN5x.js';
8
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.C3FXk5Gv.js';
9
9
  import { performance as performance$1 } from 'node:perf_hooks';
10
10
  import { startTests, collectTests } from '@vitest/runner';
11
- import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.z3ZfZiWN.js';
12
- import { g as globalExpect, v as vi } from './test.PnxXDGpZ.js';
11
+ import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.CB31_KSV.js';
12
+ import { g as globalExpect, v as vi } from './test.CBQUpOM3.js';
13
13
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
14
14
  import { createRequire } from 'node:module';
15
15
  import timers from 'node:timers';
16
16
  import timersPromises from 'node:timers/promises';
17
17
  import util from 'node:util';
18
18
  import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
19
- import { i as index } from './index.IcAjQV7n.js';
19
+ import { i as index } from './index.Dkvtd-Ku.js';
20
20
  import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.BX5Fg8C4.js';
21
21
 
22
22
  // this should only be used in Node
@@ -115,7 +115,7 @@ async function startModuleRunner(options) {
115
115
  let mocker;
116
116
  if (options.state.config.experimental.nodeLoader !== false) {
117
117
  // this additionally imports acorn/magic-string
118
- const { NativeModuleMocker } = await import('./nativeModuleMocker.wQT5wU7r.js');
118
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.Dd1Q1VIw.js');
119
119
  mocker = new NativeModuleMocker({
120
120
  async resolveId(id, importer) {
121
121
  // TODO: use import.meta.resolve instead
@@ -141,7 +141,7 @@ let _environmentTime;
141
141
  /** @experimental */
142
142
  async function setupBaseEnvironment(context) {
143
143
  if (context.config.experimental.viteModuleRunner === false) {
144
- const { setupNodeLoaderHooks } = await import('./native.mV0-490A.js');
144
+ const { setupNodeLoaderHooks } = await import('./native.DPzPHdi5.js');
145
145
  await setupNodeLoaderHooks(context);
146
146
  }
147
147
  const startTime = performance.now();
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import { normalize } from 'pathe';
4
4
  import c$2 from 'tinyrainbow';
5
5
  import { b as defaultPort, d as defaultBrowserPort } from './constants.CPYnjOGj.js';
6
- import { R as ReportersMap } from './index.DpkD7Zj4.js';
6
+ import { R as ReportersMap } from './index.DXMFO5MJ.js';
7
7
  import assert from 'node:assert';
8
8
 
9
9
  function toArr(any) {
@@ -620,7 +620,7 @@ class CAC extends EventEmitter {
620
620
 
621
621
  const cac = (name = "") => new CAC(name);
622
622
 
623
- var version = "4.1.0-beta.6";
623
+ var version = "4.1.1";
624
624
 
625
625
  const apiConfig = (port) => ({
626
626
  port: {
@@ -828,6 +828,11 @@ const cliOptionsConfig = {
828
828
  if (value === "false" || value === "no" || value === false) return false;
829
829
  return value;
830
830
  }
831
+ },
832
+ excludeAfterRemap: { description: "Apply exclusions again after coverage has been remapped to original sources. (default: false)" },
833
+ htmlDir: {
834
+ description: "Directory of HTML coverage output to be served in UI mode and HTML reporter.",
835
+ argument: "<path>"
831
836
  }
832
837
  }
833
838
  },
@@ -1167,7 +1172,7 @@ const cliOptionsConfig = {
1167
1172
  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`)",
1168
1173
  argument: "<loader>"
1169
1174
  },
1170
- 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`)" },
1175
+ standalone: { description: "Start Vitest without running tests. Tests will be running only on change. If browser mode is enabled, the UI will be opened automatically. This option is ignored when CLI file filters are passed. (default: `false`)" },
1171
1176
  mergeReports: {
1172
1177
  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",
1173
1178
  argument: "[path]",
@@ -1232,7 +1237,12 @@ const cliOptionsConfig = {
1232
1237
  }
1233
1238
  },
1234
1239
  viteModuleRunner: { description: "Control whether Vitest uses Vite's module runner to run the code or fallback to the native `import`. (default: `true`)" },
1235
- nodeLoader: { description: "Controls whether Vitest will use Node.js Loader API to process in-source or mocked files. This has no effect if `viteModuleRunner` is enabled. Disabling this can increase performance. (default: `true`)" }
1240
+ nodeLoader: { description: "Controls whether Vitest will use Node.js Loader API to process in-source or mocked files. This has no effect if `viteModuleRunner` is enabled. Disabling this can increase performance. (default: `true`)" },
1241
+ vcsProvider: {
1242
+ argument: "<path>",
1243
+ description: "Custom provider for detecting changed files. (default: `git`)",
1244
+ subcommands: null
1245
+ }
1236
1246
  }
1237
1247
  },
1238
1248
  cliExclude: null,
@@ -2312,11 +2322,11 @@ function normalizeCliOptions(cliFilters, argv) {
2312
2322
  }
2313
2323
  async function start(mode, cliFilters, options) {
2314
2324
  try {
2315
- const { startVitest } = await import('./cli-api.Bqj5xGy5.js').then(function (n) { return n.q; });
2325
+ const { startVitest } = await import('./cli-api.BUXBO6jS.js').then(function (n) { return n.q; });
2316
2326
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2317
2327
  if (!ctx.shouldKeepServer()) await ctx.exit();
2318
2328
  } catch (e) {
2319
- const { errorBanner } = await import('./index.DpkD7Zj4.js').then(function (n) { return n.A; });
2329
+ const { errorBanner } = await import('./index.DXMFO5MJ.js').then(function (n) { return n.C; });
2320
2330
  console.error(`\n${errorBanner("Startup Error")}`);
2321
2331
  console.error(e);
2322
2332
  console.error("\n\n");
@@ -2334,7 +2344,7 @@ async function init(project) {
2334
2344
  }
2335
2345
  async function collect(mode, cliFilters, options) {
2336
2346
  try {
2337
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.Bqj5xGy5.js').then(function (n) { return n.q; });
2347
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.BUXBO6jS.js').then(function (n) { return n.q; });
2338
2348
  const ctx = await prepareVitest(mode, {
2339
2349
  ...normalizeCliOptions(cliFilters, options),
2340
2350
  watch: false,
@@ -2356,7 +2366,7 @@ async function collect(mode, cliFilters, options) {
2356
2366
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
2357
2367
  await ctx.close();
2358
2368
  } catch (e) {
2359
- const { errorBanner } = await import('./index.DpkD7Zj4.js').then(function (n) { return n.A; });
2369
+ const { errorBanner } = await import('./index.DXMFO5MJ.js').then(function (n) { return n.C; });
2360
2370
  console.error(`\n${errorBanner("Collect Error")}`);
2361
2371
  console.error(e);
2362
2372
  console.error("\n\n");
@@ -1,6 +1,6 @@
1
1
  import fs, { promises, existsSync, mkdirSync, readFileSync, statSync, readdirSync, writeFileSync } from 'node:fs';
2
2
  import { relative, resolve, dirname, join, extname, normalize, basename, isAbsolute } from 'pathe';
3
- import { C as CoverageProviderMap } from './coverage.D_JHT54q.js';
3
+ import { C as CoverageProviderMap } from './coverage.CTzCuANN.js';
4
4
  import path, { resolve as resolve$1 } from 'node:path';
5
5
  import { unique, createDefer, slash, withTrailingSlash, cleanUrl, wrapId, isExternalUrl, unwrapId, toArray, noop, deepMerge, nanoid, deepClone, isPrimitive, notNullish } from '@vitest/utils/helpers';
6
6
  import { a as any, p as prompt } from './index.og1WyBLx.js';
@@ -13,13 +13,13 @@ import nodeos__default, { tmpdir } from 'node:os';
13
13
  import { generateHash as generateHash$1, createTaskName, validateTags, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, getTasks, isTestCase } from '@vitest/runner/utils';
14
14
  import { SnapshotManager } from '@vitest/snapshot/manager';
15
15
  import { serializeValue } from '@vitest/utils/serialize';
16
- import { v as version$1 } from './cac.Vtz91O0H.js';
16
+ import { v as version$1 } from './cac.CHfKU_gf.js';
17
17
  import { rootDir, distDir } from '../path.js';
18
- import { d as createIndexLocationsMap, e as TraceMap, o as originalPositionFor, h as ancestor, i as stringify, p as parse, j as printError, f as formatProjectName, w as withLabel, k as errorBanner, l as divider, m as Typechecker, n as generateCodeFrame, q as escapeRegExp, r as createDefinesScript, R as ReportersMap, u as groupBy, B as BlobReporter, v as readBlobs, x as convertTasksToEvents, H as HangingProcessReporter, y as wildcardPatternToRegExp, z as stdout } from './index.DpkD7Zj4.js';
18
+ import { d as createIndexLocationsMap, e as TraceMap, o as originalPositionFor, h as ancestor, i as stringify, p as parse, j as printError, f as formatProjectName, w as withLabel, k as errorBanner, l as divider, m as Typechecker, n as generateCodeFrame, q as escapeRegExp, r as createDefinesScript, R as ReportersMap, u as groupBy, B as BlobReporter, v as readBlobs, x as convertTasksToEvents, H as HangingProcessReporter, y as wildcardPatternToRegExp, z as stdout } from './index.DXMFO5MJ.js';
19
19
  import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
20
- import { T as Traces } from './traces.CCmnQaNT.js';
20
+ import { T as Traces } from './traces.DT5aQ62U.js';
21
21
  import { createDebug } from 'obug';
22
- import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, b as resolveApiServerConfig } from './coverage.DUqi2f6q.js';
22
+ import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, b as resolveApiServerConfig } from './coverage.CJ2HXVIG.js';
23
23
  import { rm, readFile, writeFile, rename, stat, unlink, mkdir, copyFile } from 'node:fs/promises';
24
24
  import c from 'tinyrainbow';
25
25
  import { VitestModuleEvaluator } from '#module-evaluator';
@@ -49,16 +49,17 @@ import require$$0$2 from 'stream';
49
49
  import require$$7 from 'url';
50
50
  import require$$0 from 'zlib';
51
51
  import require$$0$1 from 'buffer';
52
- import { c as configDefaults } from './defaults.BlJmGxXD.js';
52
+ import { c as configDefaults } from './defaults.CdU2lD-q.js';
53
53
  import MagicString from 'magic-string';
54
54
  import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
55
55
  import { KNOWN_ASSET_RE } from '@vitest/utils/constants';
56
56
  import { findNearestPackageData } from '@vitest/utils/resolver';
57
57
  import * as esModuleLexer from 'es-module-lexer';
58
- import { a as BenchmarkReportsMap } from './index.CHsi7RlU.js';
58
+ import { a as BenchmarkReportsMap } from './index.CEzQDJGb.js';
59
59
  import assert$1 from 'node:assert';
60
60
  import { parseErrorStacktrace } from '@vitest/utils/source-map';
61
61
  import { extractSourcemapFromFile } from '@vitest/utils/source-map/node';
62
+ import { x } from 'tinyexec';
62
63
  import readline from 'node:readline';
63
64
  import { stripVTControlCharacters } from 'node:util';
64
65
 
@@ -136,8 +137,8 @@ function astParseFile(filepath, code) {
136
137
  if (callee.type === "MemberExpression") {
137
138
  if (callee.object?.type === "Identifier" && isVitestFunctionName(callee.object.name)) return callee.object?.name;
138
139
  if (callee.object?.name?.startsWith("__vite_ssr_") || callee.object?.object?.name?.startsWith("__vite_ssr_") && callee.object?.property?.name === "Vitest") return getName(callee.property);
139
- // call as `__vite_ssr__.test.skip()`
140
- return getName(callee.object?.property);
140
+ // call as `__vite_ssr__.test.skip()` or `describe.concurrent.each()`
141
+ return getName(callee.object);
141
142
  }
142
143
  // unwrap (0, ...)
143
144
  if (callee.type === "SequenceExpression" && callee.expressions.length === 2) {
@@ -146,6 +147,18 @@ function astParseFile(filepath, code) {
146
147
  }
147
148
  return null;
148
149
  };
150
+ const getProperties = (callee) => {
151
+ if (!callee) return [];
152
+ if (callee.type === "Identifier") return [];
153
+ if (callee.type === "CallExpression") return getProperties(callee.callee);
154
+ if (callee.type === "TaggedTemplateExpression") return getProperties(callee.tag);
155
+ if (callee.type === "MemberExpression") {
156
+ const props = getProperties(callee.object);
157
+ if (callee.property?.name) props.push(callee.property.name);
158
+ return props;
159
+ }
160
+ return [];
161
+ };
149
162
  ancestor(ast, { CallExpression(node) {
150
163
  const { callee } = node;
151
164
  const name = getName(callee);
@@ -154,10 +167,10 @@ function astParseFile(filepath, code) {
154
167
  verbose?.(`Skipping ${name} (unknown call)`);
155
168
  return;
156
169
  }
170
+ const properties = getProperties(callee);
157
171
  const property = callee?.property?.name;
158
- let mode = !property || property === name ? "run" : property;
159
- // they will be picked up in the next iteration
160
- if ([
172
+ // intermediate calls like .each(), .for() will be picked up in the next iteration
173
+ if (property && [
161
174
  "each",
162
175
  "for",
163
176
  "skipIf",
@@ -165,7 +178,15 @@ function astParseFile(filepath, code) {
165
178
  "extend",
166
179
  "scoped",
167
180
  "override"
168
- ].includes(mode)) return;
181
+ ].includes(property)) return;
182
+ // skip properties on return values of calls - e.g., test('name', fn).skip()
183
+ if (callee.type === "MemberExpression" && callee.object?.type === "CallExpression") return;
184
+ // derive mode from the full chain (handles any order like .skip.concurrent or .concurrent.skip)
185
+ let mode = "run";
186
+ for (const prop of properties) if (prop === "skip" || prop === "only" || prop === "todo") mode = prop;
187
+ else if (prop === "skipIf" || prop === "runIf") mode = "skip";
188
+ let isConcurrent = properties.includes("concurrent");
189
+ let isSequential = properties.includes("sequential");
169
190
  let start;
170
191
  const end = node.end;
171
192
  // .each or (0, __vite_ssr_exports_0__.test)()
@@ -184,28 +205,28 @@ function astParseFile(filepath, code) {
184
205
  }
185
206
  if (message.startsWith("0,")) message = message.slice(2);
186
207
  message = message.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/__vi_import_\d+__\./g, "");
187
- // cannot statically analyze, so we always skip it
188
- if (mode === "skipIf" || mode === "runIf") mode = "skip";
189
208
  const parentCalleeName = typeof callee?.callee === "object" && callee?.callee.type === "MemberExpression" && callee?.callee.property?.name;
190
209
  let isDynamicEach = parentCalleeName === "each" || parentCalleeName === "for";
191
210
  if (!isDynamicEach && callee.type === "TaggedTemplateExpression") {
192
211
  const property = callee.tag?.property?.name;
193
212
  isDynamicEach = property === "each" || property === "for";
194
213
  }
195
- // Extract tags from the second argument if it's an options object
214
+ // Extract options from the second argument if it's an options object
196
215
  const tags = [];
197
216
  const secondArg = node.arguments?.[1];
198
- if (secondArg?.type === "ObjectExpression") {
199
- const tagsProperty = secondArg.properties?.find((p) => p.type === "Property" && p.key?.type === "Identifier" && p.key.name === "tags");
200
- if (tagsProperty) {
201
- const tagsValue = tagsProperty.value;
202
- if (tagsValue?.type === "Literal" && typeof tagsValue.value === "string")
203
- // tags: 'single-tag'
204
- tags.push(tagsValue.value);
217
+ if (secondArg?.type === "ObjectExpression") for (const prop of secondArg.properties || []) {
218
+ if (prop.type !== "Property" || prop.key?.type !== "Identifier") continue;
219
+ const keyName = prop.key.name;
220
+ if (keyName === "tags") {
221
+ const tagsValue = prop.value;
222
+ if (tagsValue?.type === "Literal" && typeof tagsValue.value === "string") tags.push(tagsValue.value);
205
223
  else if (tagsValue?.type === "ArrayExpression") {
206
- // tags: ['tag1', 'tag2']
207
224
  for (const element of tagsValue.elements || []) if (element?.type === "Literal" && typeof element.value === "string") tags.push(element.value);
208
225
  }
226
+ } else if (prop.value?.type === "Literal" && prop.value.value === true) {
227
+ if (keyName === "skip" || keyName === "only" || keyName === "todo") mode = keyName;
228
+ else if (keyName === "concurrent") isConcurrent = true;
229
+ else if (keyName === "sequential") isSequential = true;
209
230
  }
210
231
  }
211
232
  debug$1?.("Found", name, message, `(${mode})`, tags.length ? `[${tags.join(", ")}]` : "");
@@ -217,6 +238,8 @@ function astParseFile(filepath, code) {
217
238
  mode,
218
239
  task: null,
219
240
  dynamic: isDynamicEach,
241
+ concurrent: isConcurrent,
242
+ sequential: isSequential,
220
243
  tags
221
244
  });
222
245
  } });
@@ -311,6 +334,8 @@ function createFileTask(testFilepath, code, requestMap, config, filepath, fileTa
311
334
  } else debug$1?.("Cannot find original location for", definition.type, definition.name, `${processedLocation.column}:${processedLocation.line}`);
312
335
  } else debug$1?.("Cannot find original location for", definition.type, definition.name, `${definition.start}`);
313
336
  const taskTags = unique([...latestSuite.tags || [], ...definition.tags]);
337
+ // resolve concurrent/sequential: sequential cancels inherited concurrent
338
+ const concurrent = definition.sequential ? void 0 : definition.concurrent || latestSuite.concurrent || void 0;
314
339
  if (definition.type === "suite") {
315
340
  const task = {
316
341
  type: definition.type,
@@ -320,6 +345,7 @@ function createFileTask(testFilepath, code, requestMap, config, filepath, fileTa
320
345
  tasks: [],
321
346
  mode,
322
347
  each: definition.dynamic,
348
+ concurrent,
323
349
  name: definition.name,
324
350
  fullName: createTaskName([latestSuite.fullName, definition.name]),
325
351
  fullTestName: createTaskName([latestSuite.fullTestName, definition.name]),
@@ -342,6 +368,7 @@ function createFileTask(testFilepath, code, requestMap, config, filepath, fileTa
342
368
  suite: latestSuite,
343
369
  file,
344
370
  each: definition.dynamic,
371
+ concurrent,
345
372
  mode,
346
373
  context: {},
347
374
  name: definition.name,
@@ -431,7 +458,7 @@ class BrowserSessions {
431
458
  this.sessions.delete(sessionId);
432
459
  }
433
460
  createSession(sessionId, project, pool) {
434
- // this promise only waits for the WS connection with the orhcestrator to be established
461
+ // this promise only waits for the WS connection with the orchestrator to be established
435
462
  const defer = createDefer();
436
463
  const timeout = setTimeout(() => {
437
464
  defer.reject(/* @__PURE__ */ new Error(`Failed to connect to the browser session "${sessionId}" [${project.name}] within the timeout.`));
@@ -1178,7 +1205,7 @@ function getCachedResult(result, tmp) {
1178
1205
  invalidate: result.invalidate
1179
1206
  };
1180
1207
  }
1181
- const MODULE_RUNNER_SOURCEMAPPING_REGEXP = /* @__PURE__ */ new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
1208
+ const MODULE_RUNNER_SOURCEMAPPING_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
1182
1209
  function extractSourceMap(code) {
1183
1210
  const pattern = `//# ${SOURCEMAPPING_URL}=data:application/json;base64,`;
1184
1211
  const lastIndex = code.lastIndexOf(pattern);
@@ -1966,7 +1993,7 @@ class Logger {
1966
1993
  this.log(PAD + c.dim(c.green(`API started at ${new URL("/", origin)}`)));
1967
1994
  }
1968
1995
  if (this.ctx.coverageProvider) this.log(PAD + c.dim("Coverage enabled with ") + c.yellow(this.ctx.coverageProvider.name));
1969
- if (this.ctx.config.standalone) this.log(c.yellow(`\nVitest is running in standalone mode. Edit a test file to rerun tests.`));
1996
+ if (this.ctx.config.standalone) this.log(c.yellow(`\nVitest is running in standalone mode. Edit a test file to rerun tests.\n`));
1970
1997
  else this.log();
1971
1998
  }
1972
1999
  printBrowserBanner(project) {
@@ -2369,13 +2396,7 @@ function createBrowserPool(vitest) {
2369
2396
  const ensurePool = (project) => {
2370
2397
  if (projectPools.has(project)) return projectPools.get(project);
2371
2398
  debug?.("creating pool for project %s", project.name);
2372
- const resolvedUrls = project.browser.vite.resolvedUrls;
2373
- const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
2374
- if (!origin) throw new Error(`Can't find browser origin URL for project "${project.name}"`);
2375
- const pool = new BrowserPool(project, {
2376
- maxWorkers: getThreadsCount(project),
2377
- origin
2378
- });
2399
+ const pool = new BrowserPool(project, { maxWorkers: getThreadsCount(project) });
2379
2400
  projectPools.set(project, pool);
2380
2401
  vitest.onCancel(() => {
2381
2402
  pool.cancel();
@@ -2474,7 +2495,7 @@ class BrowserPool {
2474
2495
  _queue = [];
2475
2496
  _promise;
2476
2497
  _providedContext;
2477
- readySessions = /* @__PURE__ */ new Set();
2498
+ readySessions;
2478
2499
  _traces;
2479
2500
  _otel;
2480
2501
  constructor(project, options) {
@@ -2486,6 +2507,7 @@ class BrowserPool {
2486
2507
  "vitest.project": project.name,
2487
2508
  "vitest.browser.provider": this.project.browser.provider.name
2488
2509
  });
2510
+ this.readySessions = project._browserReadySessions;
2489
2511
  }
2490
2512
  cancel() {
2491
2513
  this._queue = [];
@@ -2542,14 +2564,10 @@ class BrowserPool {
2542
2564
  return this._promise;
2543
2565
  }
2544
2566
  async openPage(sessionId, options) {
2545
- const sessionPromise = this.project.vitest._browserSessions.createSession(sessionId, this.project, this);
2546
- const browser = this.project.browser;
2547
- const url = new URL("/__vitest_test__/", this.options.origin);
2548
- url.searchParams.set("sessionId", sessionId);
2549
- const otelCarrier = this._traces.getContextCarrier();
2550
- if (otelCarrier) url.searchParams.set("otelCarrier", JSON.stringify(otelCarrier));
2551
- const pagePromise = browser.provider.openPage(sessionId, url.toString(), options);
2552
- await Promise.all([sessionPromise, pagePromise]);
2567
+ await this.project._openBrowserPage(sessionId, {
2568
+ reject: (error) => this.reject(error),
2569
+ parallel: options.parallel
2570
+ });
2553
2571
  }
2554
2572
  getOrchestrator(sessionId) {
2555
2573
  const orchestrator = this.orchestrators.get(sessionId);
@@ -8983,7 +9001,7 @@ function setup(ctx, _server) {
8983
9001
  try {
8984
9002
  result.source = result.source || (moduleNode.file ? await promises.readFile(moduleNode.file, "utf-8") : void 0);
8985
9003
  } catch {}
8986
- // TODO: store this in HTML reporter separetly
9004
+ // TODO: store this in HTML reporter separately
8987
9005
  const transformDuration = ctx.state.metadata[projectName]?.duration[moduleNode.url]?.[0];
8988
9006
  if (transformDuration != null) result.transformTime = transformDuration;
8989
9007
  try {
@@ -9894,7 +9912,7 @@ function silenceImportViteIgnoreWarning(logger) {
9894
9912
 
9895
9913
  const cssLangs = "\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)";
9896
9914
  const cssLangRE = new RegExp(cssLangs);
9897
- const cssModuleRE = /* @__PURE__ */ new RegExp(`\\.module${cssLangs}`);
9915
+ const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
9898
9916
  const cssInlineRE = /[?&]inline(?:&|$)/;
9899
9917
  function isCSS(id) {
9900
9918
  return cssLangRE.test(id);
@@ -10177,7 +10195,7 @@ function processWildcard(dep, moduleDirectories) {
10177
10195
  if (typeof dep !== "string") return dep;
10178
10196
  if (typeof dep === "string" && dep.includes("*")) {
10179
10197
  const directories = (moduleDirectories || ["/node_modules/"]).map((r) => escapeRegExp(r));
10180
- return /* @__PURE__ */ new RegExp(`(${directories.join("|")})${dep.replace(/\*/g, "[\\w/]+")}`);
10198
+ return new RegExp(`(${directories.join("|")})${dep.replace(/\*/g, "[\\w/]+")}`);
10181
10199
  }
10182
10200
  return dep;
10183
10201
  }
@@ -10587,7 +10605,8 @@ class TestProject {
10587
10605
  /** @internal */ _resolver;
10588
10606
  /** @internal */ _fetcher;
10589
10607
  /** @internal */ _serializedDefines;
10590
- /** @inetrnal */ testFilesList = null;
10608
+ /** @internal */ testFilesList = null;
10609
+ /** @internal */ _browserReadySessions = /* @__PURE__ */ new Set();
10591
10610
  runner;
10592
10611
  closingPromise;
10593
10612
  typecheckFilesList = null;
@@ -10918,6 +10937,32 @@ class TestProject {
10918
10937
  _getViteEnvironments() {
10919
10938
  return [...Object.values(this.browser?.vite.environments || {}), ...Object.values(this.vite.environments || {})];
10920
10939
  }
10940
+ /** @internal */
10941
+ async _openBrowserPage(sessionId, pool) {
10942
+ if (!this.browser) throw new Error(`browser is not initialized`);
10943
+ const resolvedUrls = this.browser.vite.resolvedUrls;
10944
+ const origin = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
10945
+ if (!origin) throw new Error(`Can't find browser origin URL for project "${this.name}"`);
10946
+ const url = new URL("/__vitest_test__/", origin);
10947
+ url.searchParams.set("sessionId", sessionId);
10948
+ const otelCarrier = this.vitest._traces.getContextCarrier();
10949
+ if (otelCarrier) url.searchParams.set("otelCarrier", JSON.stringify(otelCarrier));
10950
+ this.vitest._browserSessions.sessionIds.add(sessionId);
10951
+ const sessionPromise = this.vitest._browserSessions.createSession(sessionId, this, pool);
10952
+ const pagePromise = this.browser.provider.openPage(sessionId, url.toString(), { parallel: pool.parallel ?? false });
10953
+ await Promise.all([sessionPromise, pagePromise]);
10954
+ }
10955
+ /** @internal */
10956
+ async _standalone() {
10957
+ if (!this.isBrowserEnabled()) return;
10958
+ await this._initBrowserProvider();
10959
+ if (!this.browser) return;
10960
+ const sessionId = crypto.randomUUID();
10961
+ await this._openBrowserPage(sessionId, { reject: (error) => {
10962
+ this.vitest.state.catchError(error, "Browser Error");
10963
+ } });
10964
+ this._browserReadySessions.add(sessionId);
10965
+ }
10921
10966
  _serializeOverriddenConfig() {
10922
10967
  // TODO: serialize the config _once_ or when needed
10923
10968
  const config = serializeConfig(this);
@@ -11414,12 +11459,10 @@ class VitestSpecifications {
11414
11459
  }
11415
11460
  async filterTestsBySource(specs) {
11416
11461
  if (this.vitest.config.changed && !this.vitest.config.related) {
11417
- const { VitestGit } = await import('./git.Bm2pzPAa.js');
11418
- const related = await new VitestGit(this.vitest.config.root).findChangedFiles({ changedSince: this.vitest.config.changed });
11419
- if (!related) {
11420
- process.exitCode = 1;
11421
- throw new GitNotFoundError();
11422
- }
11462
+ const related = await this.vitest.vcs.findChangedFiles({
11463
+ root: this.vitest.config.root,
11464
+ changedSince: this.vitest.config.changed
11465
+ });
11423
11466
  this.vitest.config.related = Array.from(new Set(related));
11424
11467
  }
11425
11468
  const related = this.vitest.config.related;
@@ -12004,7 +12047,7 @@ class StateManager {
12004
12047
  return Array.from(this.idMap.values()).filter((t) => t.result?.state === "fail").length;
12005
12048
  }
12006
12049
  cancelFiles(files, project) {
12007
- // if we don't filter existing modules, they will be overriden by `collectFiles`
12050
+ // if we don't filter existing modules, they will be overridden by `collectFiles`
12008
12051
  const nonRegisteredFiles = files.filter(({ filepath }) => {
12009
12052
  const id = generateFileHash(relative(project.config.root, filepath), project.name);
12010
12053
  return !this.idMap.has(id);
@@ -12650,6 +12693,83 @@ function sanitizeFilePath(s) {
12650
12693
  return s.replace(/[\x00-\x2C\x2E\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, "-");
12651
12694
  }
12652
12695
 
12696
+ class GitVCSProvider {
12697
+ root;
12698
+ async resolveFilesWithGitCommand(args) {
12699
+ let result;
12700
+ try {
12701
+ result = await x("git", args, { nodeOptions: { cwd: this.root } });
12702
+ } catch (e) {
12703
+ e.message = e.stderr;
12704
+ throw e;
12705
+ }
12706
+ return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
12707
+ }
12708
+ async findChangedFiles(options) {
12709
+ const root = this.root || await this.getRoot(options.root);
12710
+ if (!root) throw new GitNotFoundError();
12711
+ this.root = root;
12712
+ const changedSince = options.changedSince;
12713
+ if (typeof changedSince === "string") {
12714
+ const [committed, staged, unstaged] = await Promise.all([
12715
+ this.getFilesSince(changedSince),
12716
+ this.getStagedFiles(),
12717
+ this.getUnstagedFiles()
12718
+ ]);
12719
+ return [
12720
+ ...committed,
12721
+ ...staged,
12722
+ ...unstaged
12723
+ ];
12724
+ }
12725
+ const [staged, unstaged] = await Promise.all([this.getStagedFiles(), this.getUnstagedFiles()]);
12726
+ return [...staged, ...unstaged];
12727
+ }
12728
+ getFilesSince(hash) {
12729
+ return this.resolveFilesWithGitCommand([
12730
+ "diff",
12731
+ "--name-only",
12732
+ `${hash}...HEAD`
12733
+ ]);
12734
+ }
12735
+ getStagedFiles() {
12736
+ return this.resolveFilesWithGitCommand([
12737
+ "diff",
12738
+ "--cached",
12739
+ "--name-only"
12740
+ ]);
12741
+ }
12742
+ getUnstagedFiles() {
12743
+ return this.resolveFilesWithGitCommand([
12744
+ "ls-files",
12745
+ "--other",
12746
+ "--modified",
12747
+ "--exclude-standard"
12748
+ ]);
12749
+ }
12750
+ async getRoot(cwd) {
12751
+ const args = ["rev-parse", "--show-cdup"];
12752
+ try {
12753
+ return resolve(cwd, (await x("git", args, { nodeOptions: { cwd } })).stdout.trim());
12754
+ } catch {
12755
+ return null;
12756
+ }
12757
+ }
12758
+ }
12759
+
12760
+ async function loadVCSProvider(runner, vcsProvider) {
12761
+ if (typeof vcsProvider === "object" && vcsProvider != null) return wrapVCSProvider(vcsProvider);
12762
+ if (!vcsProvider || vcsProvider === "git") return new GitVCSProvider();
12763
+ const module = await runner.import(vcsProvider);
12764
+ if (!module.default || typeof module.default !== "object" || typeof module.default.findChangedFiles !== "function") throw new Error(`The vcsProvider module '${vcsProvider}' doesn't have a default export with \`findChangedFiles\` method.`);
12765
+ return wrapVCSProvider(module.default);
12766
+ }
12767
+ function wrapVCSProvider(provider) {
12768
+ return { async findChangedFiles(options) {
12769
+ return (await provider.findChangedFiles(options)).map((file) => resolve(options.root, file));
12770
+ } };
12771
+ }
12772
+
12653
12773
  class VitestWatcher {
12654
12774
  /**
12655
12775
  * Modules that will be invalidated on the next run.
@@ -12850,6 +12970,13 @@ class Vitest {
12850
12970
  * Vitest behaviour.
12851
12971
  */
12852
12972
  watcher;
12973
+ /**
12974
+ * The version control system provider used to detect changed files.
12975
+ * This is used with the `--changed` flag to determine which test files to run.
12976
+ * By default, Vitest uses Git. You can provide a custom implementation via
12977
+ * `experimental.vcsProvider` in your config.
12978
+ */
12979
+ vcs;
12853
12980
  /** @internal */ configOverride = {};
12854
12981
  /** @internal */ filenamePattern;
12855
12982
  /** @internal */ runningPromise;
@@ -12971,6 +13098,7 @@ class Vitest {
12971
13098
  configurable: true
12972
13099
  });
12973
13100
  }
13101
+ this.vcs = await loadVCSProvider(this.runner, resolved.experimental.vcsProvider);
12974
13102
  if (this.config.watch) {
12975
13103
  // hijack server restart
12976
13104
  const serverRestart = server.restart;
@@ -13318,10 +13446,17 @@ class Vitest {
13318
13446
  });
13319
13447
  }
13320
13448
  /**
13449
+ * @deprecated use `standalone()` instead
13450
+ */
13451
+ init() {
13452
+ this.logger.deprecate("`vitest.init()` is deprecated. Use `vitest.standalone()` instead.");
13453
+ return this.standalone();
13454
+ }
13455
+ /**
13321
13456
  * Initialize reporters and the coverage provider. This method doesn't run any tests.
13322
13457
  * If the `--watch` flag is provided, Vitest will still run changed tests even if this method was not called.
13323
13458
  */
13324
- async init() {
13459
+ async standalone() {
13325
13460
  await this._traces.$("vitest.init", async () => {
13326
13461
  try {
13327
13462
  await this.initCoverageProvider();
@@ -13331,6 +13466,7 @@ class Vitest {
13331
13466
  }
13332
13467
  // populate test files cache so watch mode can trigger a file rerun
13333
13468
  await this.globTestSpecifications();
13469
+ await Promise.all(this.projects.map((project) => project._standalone()));
13334
13470
  if (this.config.watch) await this.report("onWatcherStart");
13335
13471
  });
13336
13472
  }
@@ -14149,8 +14285,8 @@ ${c.dim(` ...and ${remainingResultCount} more ${remainingResultCount === 1 ? "
14149
14285
  if (this.stdin.isTTY) this.stdin.setRawMode(false);
14150
14286
  }
14151
14287
  restoreCursor() {
14152
- const cursortPos = this.keywordOffset() + (this.currentKeyword?.length || 0);
14153
- this.write(`${ESC}${cursortPos}G`);
14288
+ const cursorPos = this.keywordOffset() + (this.currentKeyword?.length || 0);
14289
+ this.write(`${ESC}${cursorPos}G`);
14154
14290
  }
14155
14291
  write(data) {
14156
14292
  this.stdout.write(data);
@@ -14345,14 +14481,14 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
14345
14481
  let stdinCleanup;
14346
14482
  if (stdin.isTTY && ctx.config.watch) stdinCleanup = registerConsoleShortcuts(ctx, stdin, stdout);
14347
14483
  ctx.onAfterSetServer(() => {
14348
- if (ctx.config.standalone) ctx.init();
14484
+ if (ctx.config.standalone) ctx.standalone();
14349
14485
  else ctx.start(cliFilters);
14350
14486
  });
14351
14487
  try {
14352
14488
  if (ctx.config.listTags) await ctx.listTags();
14353
14489
  else if (ctx.config.clearCache) await ctx.experimental_clearCache();
14354
14490
  else if (ctx.config.mergeReports) await ctx.mergeReports();
14355
- else if (ctx.config.standalone) await ctx.init();
14491
+ else if (ctx.config.standalone) await ctx.standalone();
14356
14492
  else await ctx.start(cliFilters);
14357
14493
  return ctx;
14358
14494
  } catch (e) {