vitest 2.0.0-beta.2 → 2.0.0-beta.3

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 (42) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.D0I8wu4f.js} +3 -3
  4. package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.CsxVA4nP.js} +4 -4
  5. package/dist/cli.js +2 -2
  6. package/dist/config.cjs +2 -2
  7. package/dist/config.d.ts +2 -2
  8. package/dist/config.js +2 -2
  9. package/dist/coverage.d.ts +1 -1
  10. package/dist/environments.d.ts +1 -1
  11. package/dist/execute.d.ts +1 -1
  12. package/dist/execute.js +1 -1
  13. package/dist/index.d.ts +9 -6
  14. package/dist/index.js +3 -3
  15. package/dist/node.d.ts +3 -2
  16. package/dist/node.js +5 -5
  17. package/dist/{reporters-DFgqsvtL.d.ts → reporters-C-3dxOaA.d.ts} +165 -108
  18. package/dist/reporters.d.ts +1 -1
  19. package/dist/reporters.js +1 -1
  20. package/dist/runners.d.ts +3 -2
  21. package/dist/runners.js +4 -1
  22. package/dist/{suite-C_sqQjdz.d.ts → suite-V5kCKZme.d.ts} +1 -1
  23. package/dist/suite.d.ts +2 -2
  24. package/dist/vendor/{base.VFkIJ66g.js → base.CfOCwoIE.js} +2 -2
  25. package/dist/vendor/{cac.CtP0aXu-.js → cac.f5m2SesE.js} +15 -8
  26. package/dist/vendor/{cli-api.B2QW76dQ.js → cli-api.pZNNj7LX.js} +139 -181
  27. package/dist/vendor/{constants.5SOfHUj0.js → constants.XmjJgDXx.js} +2 -2
  28. package/dist/vendor/{execute.CLLNVNnK.js → execute.Bwzklsfj.js} +1 -1
  29. package/dist/vendor/{index.BfoZyXD1.js → index.BHPXakMe.js} +1 -1
  30. package/dist/vendor/{index.CmILuxzC.js → index.BkeKAX-R.js} +1 -1
  31. package/dist/vendor/{index.CRxYS9H3.js → index.DOAUPIJU.js} +237 -40
  32. package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.6St9QHh1.js} +1 -1
  33. package/dist/vendor/{vi.ClD3hi7L.js → vi.B31D70yH.js} +75 -36
  34. package/dist/vendor/{vm.Bi3bljci.js → vm.rKHnSoLJ.js} +1 -1
  35. package/dist/workers/forks.js +2 -2
  36. package/dist/workers/runVmTests.js +4 -4
  37. package/dist/workers/threads.js +2 -2
  38. package/dist/workers/vmForks.js +2 -2
  39. package/dist/workers/vmThreads.js +2 -2
  40. package/dist/workers.d.ts +1 -1
  41. package/dist/workers.js +3 -3
  42. package/package.json +10 -10
@@ -1,5 +1,5 @@
1
- import { dirname, join, resolve, relative, isAbsolute, normalize, basename, toNamespacedPath } from 'pathe';
2
- import { A as API_PATH, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, b as defaultInspectPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES, c as configFiles } from './constants.5SOfHUj0.js';
1
+ import { dirname, join, resolve, isAbsolute, relative, normalize, basename, toNamespacedPath } from 'pathe';
2
+ import { A as API_PATH, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, b as defaultInspectPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES, c as configFiles } from './constants.XmjJgDXx.js';
3
3
  import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.ChSqD-qS.js';
4
4
  import { g as getEnvPackageName } from './index.DeR1hhfY.js';
5
5
  import { isFileServingAllowed, searchForWorkspaceRoot, version, createServer, mergeConfig } from 'vite';
@@ -19,13 +19,14 @@ import c from 'picocolors';
19
19
  import { ViteNodeRunner } from 'vite-node/client';
20
20
  import { SnapshotManager } from '@vitest/snapshot/manager';
21
21
  import { ViteNodeServer } from 'vite-node/server';
22
- import { v as version$1 } from './cac.CtP0aXu-.js';
23
- import { hasFailed, getTasks, getTests } from '@vitest/runner/utils';
24
- import { n as noop$2, b as isPrimitive, c as groupBy, A as AggregateErrorPonyfill, a as slash$1, t as toArray, d as deepMerge, e as nanoid, w as wildcardPatternToRegExp, f as stdout } from './base._gnK9Slw.js';
22
+ import { v as version$1 } from './cac.f5m2SesE.js';
23
+ import { hasFailed, createFileTask, getTasks, getTests } from '@vitest/runner/utils';
24
+ import { n as noop$1, b as isPrimitive, c as groupBy, A as AggregateErrorPonyfill, a as slash$1, t as toArray, d as deepMerge, e as nanoid, w as wildcardPatternToRegExp, f as stdout } from './base._gnK9Slw.js';
25
25
  import { createDefer, toArray as toArray$1, notNullish } from '@vitest/utils';
26
26
  import { a as isWindows } from './env.bmJgw1qP.js';
27
27
  import { rootDir } from '../path.js';
28
28
  import { c as createBirpc } from './index.BpSiYbpB.js';
29
+ import { s as stringify, p as parse$3, w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as findNodeAround, i as generateCodeFrame, j as highlightCode, L as Logger, k as BlobReporter, r as readBlobs } from './index.DOAUPIJU.js';
29
30
  import require$$0$4 from 'zlib';
30
31
  import require$$0$5 from 'buffer';
31
32
  import require$$1 from 'crypto';
@@ -40,7 +41,6 @@ import * as nodeos from 'node:os';
40
41
  import nodeos__default, { tmpdir } from 'node:os';
41
42
  import EventEmitter$2 from 'node:events';
42
43
  import Tinypool$1, { Tinypool } from 'tinypool';
43
- import { w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as findNodeAround, i as generateCodeFrame, j as highlightCode, L as Logger } from './index.CRxYS9H3.js';
44
44
  import crypto, { createHash as createHash$2 } from 'node:crypto';
45
45
  import { mkdir, writeFile, rm } from 'node:fs/promises';
46
46
  import { builtinModules, createRequire } from 'node:module';
@@ -1790,8 +1790,8 @@ function fastqueue (context, worker, concurrency) {
1790
1790
 
1791
1791
  var self = {
1792
1792
  push: push,
1793
- drain: noop$1,
1794
- saturated: noop$1,
1793
+ drain: noop,
1794
+ saturated: noop,
1795
1795
  pause: pause,
1796
1796
  paused: false,
1797
1797
  concurrency: concurrency,
@@ -1801,7 +1801,7 @@ function fastqueue (context, worker, concurrency) {
1801
1801
  length: length,
1802
1802
  getQueue: getQueue,
1803
1803
  unshift: unshift,
1804
- empty: noop$1,
1804
+ empty: noop,
1805
1805
  kill: kill,
1806
1806
  killAndDrain: killAndDrain,
1807
1807
  error: error
@@ -1860,7 +1860,7 @@ function fastqueue (context, worker, concurrency) {
1860
1860
  current.context = context;
1861
1861
  current.release = release;
1862
1862
  current.value = value;
1863
- current.callback = done || noop$1;
1863
+ current.callback = done || noop;
1864
1864
  current.errorHandler = errorHandler;
1865
1865
 
1866
1866
  if (_running === self.concurrency || self.paused) {
@@ -1884,7 +1884,7 @@ function fastqueue (context, worker, concurrency) {
1884
1884
  current.context = context;
1885
1885
  current.release = release;
1886
1886
  current.value = value;
1887
- current.callback = done || noop$1;
1887
+ current.callback = done || noop;
1888
1888
 
1889
1889
  if (_running === self.concurrency || self.paused) {
1890
1890
  if (queueHead) {
@@ -1928,14 +1928,14 @@ function fastqueue (context, worker, concurrency) {
1928
1928
  function kill () {
1929
1929
  queueHead = null;
1930
1930
  queueTail = null;
1931
- self.drain = noop$1;
1931
+ self.drain = noop;
1932
1932
  }
1933
1933
 
1934
1934
  function killAndDrain () {
1935
1935
  queueHead = null;
1936
1936
  queueTail = null;
1937
1937
  self.drain();
1938
- self.drain = noop$1;
1938
+ self.drain = noop;
1939
1939
  }
1940
1940
 
1941
1941
  function error (handler) {
@@ -1943,13 +1943,13 @@ function fastqueue (context, worker, concurrency) {
1943
1943
  }
1944
1944
  }
1945
1945
 
1946
- function noop$1 () {}
1946
+ function noop () {}
1947
1947
 
1948
1948
  function Task () {
1949
1949
  this.value = null;
1950
- this.callback = noop$1;
1950
+ this.callback = noop;
1951
1951
  this.next = null;
1952
- this.release = noop$1;
1952
+ this.release = noop;
1953
1953
  this.context = null;
1954
1954
  this.errorHandler = null;
1955
1955
 
@@ -1960,7 +1960,7 @@ function Task () {
1960
1960
  var errorHandler = self.errorHandler;
1961
1961
  var val = self.value;
1962
1962
  self.value = null;
1963
- self.callback = noop$1;
1963
+ self.callback = noop;
1964
1964
  if (self.errorHandler) {
1965
1965
  errorHandler(err, val);
1966
1966
  }
@@ -2008,7 +2008,7 @@ function queueAsPromised (context, worker, concurrency) {
2008
2008
  // Let's fork the promise chain to
2009
2009
  // make the error bubble up to the user but
2010
2010
  // not lead to a unhandledRejection
2011
- p.catch(noop$1);
2011
+ p.catch(noop);
2012
2012
 
2013
2013
  return p
2014
2014
  }
@@ -2027,7 +2027,7 @@ function queueAsPromised (context, worker, concurrency) {
2027
2027
  // Let's fork the promise chain to
2028
2028
  // make the error bubble up to the user but
2029
2029
  // not lead to a unhandledRejection
2030
- p.catch(noop$1);
2030
+ p.catch(noop);
2031
2031
 
2032
2032
  return p
2033
2033
  }
@@ -3128,113 +3128,6 @@ var out = FastGlob;
3128
3128
 
3129
3129
  var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
3130
3130
 
3131
- /// <reference types="../types/index.d.ts" />
3132
-
3133
- // (c) 2020-present Andrea Giammarchi
3134
-
3135
- const {parse: $parse, stringify: $stringify} = JSON;
3136
- const {keys: keys$1} = Object;
3137
-
3138
- const Primitive = String; // it could be Number
3139
- const primitive = 'string'; // it could be 'number'
3140
-
3141
- const ignore = {};
3142
- const object = 'object';
3143
-
3144
- const noop = (_, value) => value;
3145
-
3146
- const primitives = value => (
3147
- value instanceof Primitive ? Primitive(value) : value
3148
- );
3149
-
3150
- const Primitives = (_, value) => (
3151
- typeof value === primitive ? new Primitive(value) : value
3152
- );
3153
-
3154
- const revive = (input, parsed, output, $) => {
3155
- const lazy = [];
3156
- for (let ke = keys$1(output), {length} = ke, y = 0; y < length; y++) {
3157
- const k = ke[y];
3158
- const value = output[k];
3159
- if (value instanceof Primitive) {
3160
- const tmp = input[value];
3161
- if (typeof tmp === object && !parsed.has(tmp)) {
3162
- parsed.add(tmp);
3163
- output[k] = ignore;
3164
- lazy.push({k, a: [input, parsed, tmp, $]});
3165
- }
3166
- else
3167
- output[k] = $.call(output, k, tmp);
3168
- }
3169
- else if (output[k] !== ignore)
3170
- output[k] = $.call(output, k, value);
3171
- }
3172
- for (let {length} = lazy, i = 0; i < length; i++) {
3173
- const {k, a} = lazy[i];
3174
- output[k] = $.call(output, k, revive.apply(null, a));
3175
- }
3176
- return output;
3177
- };
3178
-
3179
- const set = (known, input, value) => {
3180
- const index = Primitive(input.push(value) - 1);
3181
- known.set(value, index);
3182
- return index;
3183
- };
3184
-
3185
- /**
3186
- * Converts a specialized flatted string into a JS value.
3187
- * @param {string} text
3188
- * @param {(this: any, key: string, value: any) => any} [reviver]
3189
- * @returns {any}
3190
- */
3191
- const parse$3 = (text, reviver) => {
3192
- const input = $parse(text, Primitives).map(primitives);
3193
- const value = input[0];
3194
- const $ = reviver || noop;
3195
- const tmp = typeof value === object && value ?
3196
- revive(input, new Set, value, $) :
3197
- value;
3198
- return $.call({'': tmp}, '', tmp);
3199
- };
3200
-
3201
- /**
3202
- * Converts a JS value into a specialized flatted string.
3203
- * @param {any} value
3204
- * @param {((this: any, key: string, value: any) => any) | (string | number)[] | null | undefined} [replacer]
3205
- * @param {string | number | undefined} [space]
3206
- * @returns {string}
3207
- */
3208
- const stringify = (value, replacer, space) => {
3209
- const $ = replacer && typeof replacer === object ?
3210
- (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
3211
- (replacer || noop);
3212
- const known = new Map;
3213
- const input = [];
3214
- const output = [];
3215
- let i = +set(known, input, $.call({'': value}, '', value));
3216
- let firstRun = !i;
3217
- while (i < input.length) {
3218
- firstRun = true;
3219
- output[i] = $stringify(input[i++], replace, space);
3220
- }
3221
- return '[' + output.join(',') + ']';
3222
- function replace(key, value) {
3223
- if (firstRun) {
3224
- firstRun = !firstRun;
3225
- return value;
3226
- }
3227
- const after = $.call(this, key, value);
3228
- switch (typeof after) {
3229
- case object:
3230
- if (after === null) return after;
3231
- case primitive:
3232
- return known.get(after) || set(known, input, after);
3233
- }
3234
- return after;
3235
- }
3236
- };
3237
-
3238
3131
  var bufferUtil$1 = {exports: {}};
3239
3132
 
3240
3133
  var constants = {
@@ -7817,6 +7710,19 @@ function setup(vitestOrWorkspace, _server) {
7817
7710
  return ctx.state.getUnhandledErrors();
7818
7711
  },
7819
7712
  // TODO: have a separate websocket conection for private browser API
7713
+ triggerCommand(command, testPath, payload) {
7714
+ var _a2;
7715
+ if (!("ctx" in vitestOrWorkspace) || !vitestOrWorkspace.browserProvider)
7716
+ throw new Error("Commands are only available for browser tests.");
7717
+ const commands = (_a2 = vitestOrWorkspace.config.browser) == null ? void 0 : _a2.commands;
7718
+ if (!commands || !commands[command])
7719
+ throw new Error(`Unknown command "${command}".`);
7720
+ return commands[command]({
7721
+ testPath,
7722
+ project: vitestOrWorkspace,
7723
+ provider: vitestOrWorkspace.browserProvider
7724
+ }, ...payload);
7725
+ },
7820
7726
  getBrowserFiles() {
7821
7727
  var _a2;
7822
7728
  if (!("ctx" in vitestOrWorkspace))
@@ -7834,7 +7740,10 @@ function setup(vitestOrWorkspace, _server) {
7834
7740
  },
7835
7741
  async getTestFiles() {
7836
7742
  const spec = await ctx.globTestFiles();
7837
- return spec.map(([project, file]) => [project.getName(), file]);
7743
+ return spec.map(([project, file]) => [{
7744
+ name: project.getName(),
7745
+ root: project.config.root
7746
+ }, file]);
7838
7747
  }
7839
7748
  },
7840
7749
  {
@@ -7867,7 +7776,15 @@ class WebSocketReporter {
7867
7776
  return;
7868
7777
  this.clients.forEach((client) => {
7869
7778
  var _a, _b, _c;
7870
- (_c = (_b = (_a = client.onCollected) == null ? void 0 : _a.call(client, files)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
7779
+ (_c = (_b = (_a = client.onCollected) == null ? void 0 : _a.call(client, files)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
7780
+ });
7781
+ }
7782
+ onSpecsCollected(specs) {
7783
+ if (this.clients.size === 0)
7784
+ return;
7785
+ this.clients.forEach((client) => {
7786
+ var _a, _b, _c;
7787
+ (_c = (_b = (_a = client.onSpecsCollected) == null ? void 0 : _a.call(client, specs)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
7871
7788
  });
7872
7789
  }
7873
7790
  async onTaskUpdate(packs) {
@@ -7886,25 +7803,25 @@ class WebSocketReporter {
7886
7803
  });
7887
7804
  this.clients.forEach((client) => {
7888
7805
  var _a, _b, _c;
7889
- (_c = (_b = (_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
7806
+ (_c = (_b = (_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
7890
7807
  });
7891
7808
  }
7892
7809
  onFinished(files, errors) {
7893
7810
  this.clients.forEach((client) => {
7894
7811
  var _a, _b, _c;
7895
- (_c = (_b = (_a = client.onFinished) == null ? void 0 : _a.call(client, files, errors)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
7812
+ (_c = (_b = (_a = client.onFinished) == null ? void 0 : _a.call(client, files, errors)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
7896
7813
  });
7897
7814
  }
7898
7815
  onFinishedReportCoverage() {
7899
7816
  this.clients.forEach((client) => {
7900
7817
  var _a, _b, _c;
7901
- (_c = (_b = (_a = client.onFinishedReportCoverage) == null ? void 0 : _a.call(client)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
7818
+ (_c = (_b = (_a = client.onFinishedReportCoverage) == null ? void 0 : _a.call(client)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
7902
7819
  });
7903
7820
  }
7904
7821
  onUserConsoleLog(log) {
7905
7822
  this.clients.forEach((client) => {
7906
7823
  var _a, _b, _c;
7907
- (_c = (_b = (_a = client.onUserConsoleLog) == null ? void 0 : _a.call(client, log)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$2);
7824
+ (_c = (_b = (_a = client.onUserConsoleLog) == null ? void 0 : _a.call(client, log)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
7908
7825
  });
7909
7826
  }
7910
7827
  }
@@ -7932,7 +7849,7 @@ async function groupFilesByEnv(files) {
7932
7849
  const filesWithEnv = await Promise.all(files.map(async ([project, file]) => {
7933
7850
  var _a, _b;
7934
7851
  const code = await promises$1.readFile(file, "utf-8");
7935
- let env = (_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1];
7852
+ let env = (_a = code.match(/@(?:vitest|jest)-environment\s+([\w-]+)\b/)) == null ? void 0 : _a[1];
7936
7853
  if (!env) {
7937
7854
  for (const [glob, target] of project.config.environmentMatchGlobs || []) {
7938
7855
  if (mm.isMatch(file, glob, { cwd: project.config.root })) {
@@ -8420,7 +8337,7 @@ function stringToBytes(input, percentageReference) {
8420
8337
  return input;
8421
8338
  if (typeof input === "string") {
8422
8339
  if (Number.isNaN(Number.parseFloat(input.slice(-1)))) {
8423
- let [, numericString, trailingChars] = input.match(/(.*?)([^0-9.-]+)$/i) || [];
8340
+ let [, numericString, trailingChars] = input.match(/(.*?)([^0-9.-]+)$/) || [];
8424
8341
  if (trailingChars && numericString) {
8425
8342
  const numericValue = Number.parseFloat(numericString);
8426
8343
  trailingChars = trailingChars.toLowerCase();
@@ -9068,6 +8985,9 @@ class StateManager {
9068
8985
  files.forEach((file) => {
9069
8986
  const existing = this.filesMap.get(file.filepath) || [];
9070
8987
  const otherProject = existing.filter((i) => i.projectName !== file.projectName);
8988
+ const currentFile = existing.find((i) => i.projectName === file.projectName);
8989
+ if (currentFile)
8990
+ file.logs = currentFile.logs;
9071
8991
  otherProject.push(file);
9072
8992
  this.filesMap.set(file.filepath, otherProject);
9073
8993
  this.updateId(file);
@@ -9078,13 +8998,21 @@ class StateManager {
9078
8998
  const project = _project;
9079
8999
  paths.forEach((path) => {
9080
9000
  const files = this.filesMap.get(path);
9081
- if (!files)
9001
+ const fileTask = createFileTask(path, project.config.root, project.config.name);
9002
+ this.idMap.set(fileTask.id, fileTask);
9003
+ if (!files) {
9004
+ this.filesMap.set(path, [fileTask]);
9082
9005
  return;
9006
+ }
9083
9007
  const filtered = files.filter((file) => file.projectName !== project.config.name);
9084
- if (!filtered.length)
9085
- this.filesMap.delete(path);
9086
- else
9087
- this.filesMap.set(path, filtered);
9008
+ if (!filtered.length) {
9009
+ this.filesMap.set(path, [fileTask]);
9010
+ } else {
9011
+ this.filesMap.set(path, [
9012
+ ...filtered,
9013
+ fileTask
9014
+ ]);
9015
+ }
9088
9016
  });
9089
9017
  }
9090
9018
  updateId(task) {
@@ -9123,25 +9051,7 @@ class StateManager {
9123
9051
  }).length;
9124
9052
  }
9125
9053
  cancelFiles(files, root, projectName) {
9126
- this.collectFiles(files.map((filepath) => {
9127
- const file = {
9128
- filepath,
9129
- name: relative(root, filepath),
9130
- id: filepath,
9131
- mode: "skip",
9132
- type: "suite",
9133
- result: {
9134
- state: "skip"
9135
- },
9136
- meta: {},
9137
- // Cancelled files have not yet collected tests
9138
- tasks: [],
9139
- projectName,
9140
- file: null
9141
- };
9142
- file.file = file;
9143
- return file;
9144
- }));
9054
+ this.collectFiles(files.map((filepath) => createFileTask(filepath, root, projectName)));
9145
9055
  }
9146
9056
  }
9147
9057
 
@@ -11554,6 +11464,8 @@ function resolveConfig(mode, options, viteConfig, logger) {
11554
11464
  }
11555
11465
  if (resolved.standalone && !resolved.watch)
11556
11466
  throw new Error(`Vitest standalone mode requires --watch`);
11467
+ if (resolved.mergeReports && resolved.watch)
11468
+ throw new Error(`Cannot merge reports with --watch enabled`);
11557
11469
  if (resolved.maxWorkers)
11558
11470
  resolved.maxWorkers = Number(resolved.maxWorkers);
11559
11471
  if (resolved.minWorkers)
@@ -11573,8 +11485,6 @@ function resolveConfig(mode, options, viteConfig, logger) {
11573
11485
  throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
11574
11486
  }
11575
11487
  }
11576
- if (resolved.coverage.provider === "c8")
11577
- throw new Error('"coverage.provider: c8" is not supported anymore. Use "coverage.provider: v8" instead');
11578
11488
  if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
11579
11489
  throw new Error("@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead");
11580
11490
  if (resolved.coverage.enabled && resolved.coverage.reportsDirectory) {
@@ -11901,7 +11811,7 @@ function getBetterEnd(code, node) {
11901
11811
  end += 1;
11902
11812
  return end;
11903
11813
  }
11904
- const regexpHoistable = /\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted|doMock|doUnmock)\(/;
11814
+ const regexpHoistable = /\b(?:vi|vitest)\s*\.\s*(?:mock|unmock|hoisted|doMock|doUnmock)\(/;
11905
11815
  const hashbangRE = /^#!.*\n/;
11906
11816
  function hoistMocks(code, id, parse, colors) {
11907
11817
  var _a;
@@ -12345,10 +12255,10 @@ function generateScopedClassName(strategy, name, filename) {
12345
12255
  return `_${name}_${hash}`;
12346
12256
  }
12347
12257
 
12348
- const cssLangs = "\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)";
12258
+ const cssLangs = "\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)";
12349
12259
  const cssLangRE = new RegExp(cssLangs);
12350
12260
  const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
12351
- const cssInlineRE = /[?&]inline(&|$)/;
12261
+ const cssInlineRE = /[?&]inline(?:&|$)/;
12352
12262
  function isCSS(id) {
12353
12263
  return cssLangRE.test(id);
12354
12264
  }
@@ -12960,7 +12870,7 @@ function NormalizeURLPlugin() {
12960
12870
  if (ssr || !code.includes("new URL") || !code.includes("import.meta.url"))
12961
12871
  return;
12962
12872
  const cleanString = stripLiteral(code);
12963
- const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g;
12873
+ const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g;
12964
12874
  let updatedCode = code;
12965
12875
  let match;
12966
12876
  while (match = assetImportMetaUrlRE.exec(cleanString)) {
@@ -13419,6 +13329,10 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
13419
13329
  env: {
13420
13330
  ...(_v = this.server) == null ? void 0 : _v.config.env,
13421
13331
  ...this.config.env
13332
+ },
13333
+ browser: {
13334
+ ...this.ctx.config.browser,
13335
+ commands: {}
13422
13336
  }
13423
13337
  }, this.ctx.configOverride || {});
13424
13338
  }
@@ -13620,6 +13534,9 @@ class Vitest {
13620
13534
  const projectName = task.projectName || ((_a = task == null ? void 0 : task.file) == null ? void 0 : _a.projectName);
13621
13535
  return this.projects.find((p) => p.getName() === projectName) || this.getCoreWorkspaceProject() || this.projects[0];
13622
13536
  }
13537
+ getProjectByName(name) {
13538
+ return this.projects.find((p) => p.getName() === name) || this.getCoreWorkspaceProject() || this.projects[0];
13539
+ }
13623
13540
  async getWorkspaceConfigPath() {
13624
13541
  if (this.config.workspace)
13625
13542
  return this.config.workspace;
@@ -13766,6 +13683,47 @@ class Vitest {
13766
13683
  async initBrowserProviders() {
13767
13684
  return Promise.all(this.projects.map((w) => w.initBrowserProvider()));
13768
13685
  }
13686
+ async mergeReports() {
13687
+ if (this.reporters.some((r) => r instanceof BlobReporter))
13688
+ throw new Error("Cannot merge reports when `--reporter=blob` is used. Remove blob reporter from the config first.");
13689
+ const { files, errors } = await readBlobs(this.config.mergeReports, this.projects);
13690
+ await this.report("onInit", this);
13691
+ await this.report("onPathsCollected", files.flatMap((f) => f.filepath));
13692
+ const workspaceSpecs = /* @__PURE__ */ new Map();
13693
+ for (const file of files) {
13694
+ const project = this.getProjectByName(file.projectName);
13695
+ const specs = workspaceSpecs.get(project) || [];
13696
+ specs.push(file);
13697
+ workspaceSpecs.set(project, specs);
13698
+ }
13699
+ for (const [project, files2] of workspaceSpecs) {
13700
+ const filepaths = files2.map((f) => f.filepath);
13701
+ this.state.clearFiles(project, filepaths);
13702
+ files2.forEach((file) => {
13703
+ var _a;
13704
+ (_a = file.logs) == null ? void 0 : _a.forEach((log) => this.state.updateUserLog(log));
13705
+ });
13706
+ this.state.collectFiles(files2);
13707
+ }
13708
+ await this.report("onCollected", files).catch(noop$1);
13709
+ for (const file of files) {
13710
+ const logs = [];
13711
+ const taskPacks = [];
13712
+ const tasks = getTasks(file);
13713
+ for (const task of tasks) {
13714
+ if (task.logs)
13715
+ logs.push(...task.logs);
13716
+ taskPacks.push([task.id, task.result, task.meta]);
13717
+ }
13718
+ logs.sort((log1, log2) => log1.time - log2.time);
13719
+ for (const log of logs)
13720
+ await this.report("onUserConsoleLog", log).catch(noop$1);
13721
+ await this.report("onTaskUpdate", taskPacks).catch(noop$1);
13722
+ }
13723
+ if (hasFailed(files))
13724
+ process.exitCode = 1;
13725
+ await this.report("onFinished", files, errors);
13726
+ }
13769
13727
  async start(filters) {
13770
13728
  var _a, _b;
13771
13729
  this._onClose = [];
@@ -13884,11 +13842,14 @@ class Vitest {
13884
13842
  const vitestDir = projectVitestPath ? resolve(projectVitestPath.id, "../..") : rootDir;
13885
13843
  this.distPath = join(vitestDir, "dist");
13886
13844
  }
13887
- async runFiles(paths, allTestsRun) {
13845
+ async runFiles(specs, allTestsRun) {
13888
13846
  await this.initializeDistPath();
13889
- const filepaths = paths.map(([, file]) => file);
13847
+ const filepaths = specs.map(([, file]) => file);
13890
13848
  this.state.collectPaths(filepaths);
13891
13849
  await this.report("onPathsCollected", filepaths);
13850
+ await this.report("onSpecsCollected", specs.map(
13851
+ ([project, file]) => [{ name: project.getName(), root: project.config.root }, file]
13852
+ ));
13892
13853
  await this.runningPromise;
13893
13854
  this._onCancelListeners = [];
13894
13855
  this.isCancelling = false;
@@ -13902,9 +13863,9 @@ class Vitest {
13902
13863
  this.state.clearErrors();
13903
13864
  if (!this.isFirstRun && this.config.coverage.cleanOnRerun)
13904
13865
  await ((_a = this.coverageProvider) == null ? void 0 : _a.clean());
13905
- await this.initializeGlobalSetup(paths);
13866
+ await this.initializeGlobalSetup(specs);
13906
13867
  try {
13907
- await this.pool.runTests(paths, invalidates);
13868
+ await this.pool.runTests(specs, invalidates);
13908
13869
  } catch (err) {
13909
13870
  this.state.catchError(err, "Unhandled Error");
13910
13871
  }
@@ -13914,8 +13875,8 @@ class Vitest {
13914
13875
  this.cache.results.updateResults(files);
13915
13876
  await this.cache.results.writeToCache();
13916
13877
  })().finally(async () => {
13917
- const specs = Array.from(new Set(paths.map(([, p]) => p)));
13918
- await this.report("onFinished", this.state.getFiles(specs), this.state.getUnhandledErrors());
13878
+ const files = Array.from(new Set(specs.map(([, p]) => p)));
13879
+ await this.report("onFinished", this.state.getFiles(files), this.state.getUnhandledErrors());
13919
13880
  await this.reportCoverage(allTestsRun);
13920
13881
  this.runningPromise = void 0;
13921
13882
  this.isFirstRun = false;
@@ -14037,7 +13998,7 @@ class Vitest {
14037
13998
  tests.map((test) => slash$1(test))
14038
13999
  );
14039
14000
  }
14040
- unregisterWatcher = noop$2;
14001
+ unregisterWatcher = noop$1;
14041
14002
  registerWatcher() {
14042
14003
  const updateLastChanged = (filepath) => {
14043
14004
  const projects = this.getModuleProjects(filepath);
@@ -14101,7 +14062,7 @@ class Vitest {
14101
14062
  watcher.off("change", onChange);
14102
14063
  watcher.off("unlink", onUnlink);
14103
14064
  watcher.off("add", onAdd);
14104
- this.unregisterWatcher = noop$2;
14065
+ this.unregisterWatcher = noop$1;
14105
14066
  };
14106
14067
  }
14107
14068
  /**
@@ -14396,14 +14357,9 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14396
14357
  console.log("[debug] watcher is ready");
14397
14358
  });
14398
14359
  }
14399
- try {
14400
- await ctx.setServer(options, server, userConfig);
14401
- if (options.api && options.watch)
14402
- (await Promise.resolve().then(function () { return setup$1; })).setup(ctx);
14403
- } catch (err) {
14404
- ctx.logger.printError(err, { fullStack: true });
14405
- process.exit(1);
14406
- }
14360
+ await ctx.setServer(options, server, userConfig);
14361
+ if (options.api && options.watch)
14362
+ (await Promise.resolve().then(function () { return setup$1; })).setup(ctx);
14407
14363
  if (!options.watch)
14408
14364
  await server.watcher.close();
14409
14365
  }
@@ -21038,7 +20994,9 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
21038
20994
  ctx.start(cliFilters);
21039
20995
  });
21040
20996
  try {
21041
- if (ctx.config.standalone)
20997
+ if (ctx.config.mergeReports)
20998
+ await ctx.mergeReports();
20999
+ else if (ctx.config.standalone)
21042
21000
  await ctx.init();
21043
21001
  else
21044
21002
  await ctx.start(cliFilters);
@@ -4,8 +4,8 @@ const defaultInspectPort = 9229;
4
4
  const EXIT_CODE_RESTART = 43;
5
5
  const API_PATH = "/__vitest_api__";
6
6
  const extraInlineDeps = [
7
- /^(?!.*(?:node_modules)).*\.mjs$/,
8
- /^(?!.*(?:node_modules)).*\.cjs\.js$/,
7
+ /^(?!.*node_modules).*\.mjs$/,
8
+ /^(?!.*node_modules).*\.cjs\.js$/,
9
9
  // Vite client
10
10
  /vite\w*\/dist\/client\/env.mjs/,
11
11
  // Nuxt
@@ -368,7 +368,7 @@ async function createVitestExecutor(options) {
368
368
  return runner;
369
369
  }
370
370
  const externalizeMap = /* @__PURE__ */ new Map();
371
- const bareVitestRegexp = /^@?vitest(\/|$)/;
371
+ const bareVitestRegexp = /^@?vitest(?:\/|$)/;
372
372
  const dispose = [];
373
373
  function listenForErrors(state) {
374
374
  dispose.forEach((fn) => fn());
@@ -4,7 +4,7 @@ import { distDir } from '../path.js';
4
4
  import { g as getWorkerState } from './global.7bFbnyXl.js';
5
5
  import { r as rpc } from './rpc.DRDE9Pu1.js';
6
6
  import { t as takeCoverageInsideWorker } from './coverage.ChSqD-qS.js';
7
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.XeoZAW8t.js';
7
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.6St9QHh1.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);
@@ -1,7 +1,7 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
2
  import { b as bench } from './benchmark.BNLebNi5.js';
3
3
  import { i as isFirstRun, a as runOnce } from './run-once.DLomgGUH.js';
4
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.ClD3hi7L.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.B31D70yH.js';
5
5
  import { g as getWorkerState } from './global.7bFbnyXl.js';
6
6
  import * as chai from 'chai';
7
7
  import { assert, should } from 'chai';