vitest 4.0.8 → 4.0.10

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 (56) hide show
  1. package/dist/browser.d.ts +2 -2
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
  4. package/dist/chunks/{base.BgTO2qAg.js → base.BFVArrYW.js} +6 -6
  5. package/dist/chunks/{browser.d.DTTM2PTh.d.ts → browser.d.DnU_kh8a.d.ts} +1 -1
  6. package/dist/chunks/{cac.CfkWq8Qy.js → cac.D9CYcNPM.js} +7 -7
  7. package/dist/chunks/{cli-api.BQ-bjcRi.js → cli-api.RnIE1JbW.js} +65 -63
  8. package/dist/chunks/{coverage.NVjCOln1.js → coverage.BUlIqJrL.js} +11 -11
  9. package/dist/chunks/{creator.fzVyoMf3.js → creator.DU9qFjsW.js} +2 -2
  10. package/dist/chunks/{global.d.DVdCfKp5.d.ts → global.d.BQDgW9Pr.d.ts} +1 -1
  11. package/dist/chunks/{globals.DOh96BiR.js → globals.NLOzC_A5.js} +3 -3
  12. package/dist/chunks/{index.DAL392Ss.js → index.0kCJoeWi.js} +94 -75
  13. package/dist/chunks/{index.op2Re5rn.js → index.B8lJfb0J.js} +1 -1
  14. package/dist/chunks/{index.kotH7DY7.js → index.BYek7GgP.js} +5 -3
  15. package/dist/chunks/{index.Dc3xnDvT.js → index.D4KonVSU.js} +5 -5
  16. package/dist/chunks/{index.DIFZf73e.js → index.DZ-mI_Nm.js} +1 -1
  17. package/dist/chunks/{index.BY4-tcno.js → index.Dua7TZg_.js} +3 -3
  18. package/dist/chunks/{index.DfKyPFVi.js → index.QWbK7rHY.js} +9 -3
  19. package/dist/chunks/init-forks.BZSlxfwV.js +32 -0
  20. package/dist/chunks/{init-threads.Cm4OCIWA.js → init-threads.CwE2n-Bv.js} +1 -1
  21. package/dist/chunks/{init.DMDG-idf.js → init.Cz2kTB9a.js} +3 -3
  22. package/dist/chunks/{moduleRunner.d.CzOZ_4wC.d.ts → moduleRunner.d.BxT-OjLR.d.ts} +1 -1
  23. package/dist/chunks/{plugin.d.D4RrtywJ.d.ts → plugin.d.C6KrdvNG.d.ts} +1 -1
  24. package/dist/chunks/{reporters.d.Da1D1VbQ.d.ts → reporters.d.keG-yFSu.d.ts} +4 -3
  25. package/dist/chunks/{rpc.BUV7uWKJ.js → rpc.BytlcPfC.js} +1 -1
  26. package/dist/chunks/{setup-common.LGjNSzXp.js → setup-common.BOzbXE3x.js} +2 -2
  27. package/dist/chunks/{startModuleRunner.BOmUtLIO.js → startModuleRunner.DLjmA_wU.js} +9 -9
  28. package/dist/chunks/{test.ClrAtjMv.js → test.BPErLMrw.js} +2 -2
  29. package/dist/chunks/{vi.Bgcdy3bQ.js → vi.BiaV1qII.js} +8 -8
  30. package/dist/chunks/{vm.BIkCDs68.js → vm.wSHjz-et.js} +11 -11
  31. package/dist/chunks/{worker.d.DadbA89M.d.ts → worker.d.ZGohxCEd.d.ts} +44 -5
  32. package/dist/cli.js +2 -2
  33. package/dist/config.d.ts +5 -5
  34. package/dist/coverage.d.ts +3 -3
  35. package/dist/coverage.js +1 -1
  36. package/dist/environments.js +1 -1
  37. package/dist/index.d.ts +7 -7
  38. package/dist/index.js +3 -3
  39. package/dist/module-evaluator.d.ts +2 -2
  40. package/dist/module-evaluator.js +6 -6
  41. package/dist/module-runner.js +1 -1
  42. package/dist/node.d.ts +7 -7
  43. package/dist/node.js +12 -12
  44. package/dist/reporters.d.ts +3 -3
  45. package/dist/reporters.js +2 -2
  46. package/dist/runners.js +5 -5
  47. package/dist/worker.d.ts +1 -1
  48. package/dist/worker.js +12 -12
  49. package/dist/workers/forks.js +13 -14
  50. package/dist/workers/runVmTests.js +8 -8
  51. package/dist/workers/threads.js +13 -13
  52. package/dist/workers/vmForks.js +7 -8
  53. package/dist/workers/vmThreads.js +7 -7
  54. package/package.json +15 -15
  55. package/dist/chunks/_commonjsHelpers.BFTU3MAI.js +0 -7
  56. package/dist/chunks/init-forks.2hx7cf78.js +0 -65
@@ -7,7 +7,7 @@ function defaultSerialize(i) {
7
7
  const defaultDeserialize = defaultSerialize;
8
8
  const { clearTimeout, setTimeout } = globalThis;
9
9
  const random = Math.random.bind(Math);
10
- function createBirpc(functions, options) {
10
+ function createBirpc($functions, options) {
11
11
  const {
12
12
  post,
13
13
  on,
@@ -20,83 +20,100 @@ function createBirpc(functions, options) {
20
20
  bind = "rpc",
21
21
  timeout = DEFAULT_TIMEOUT
22
22
  } = options;
23
- const rpcPromiseMap = /* @__PURE__ */ new Map();
23
+ let $closed = false;
24
+ const _rpcPromiseMap = /* @__PURE__ */ new Map();
24
25
  let _promiseInit;
25
- let closed = false;
26
+ async function _call(method, args, event, optional) {
27
+ if ($closed)
28
+ throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
29
+ const req = { m: method, a: args, t: TYPE_REQUEST };
30
+ if (optional)
31
+ req.o = true;
32
+ const send = async (_req) => post(serialize(_req));
33
+ if (event) {
34
+ await send(req);
35
+ return;
36
+ }
37
+ if (_promiseInit) {
38
+ try {
39
+ await _promiseInit;
40
+ } finally {
41
+ _promiseInit = void 0;
42
+ }
43
+ }
44
+ let { promise, resolve, reject } = createPromiseWithResolvers();
45
+ const id = nanoid();
46
+ req.i = id;
47
+ let timeoutId;
48
+ async function handler(newReq = req) {
49
+ if (timeout >= 0) {
50
+ timeoutId = setTimeout(() => {
51
+ try {
52
+ const handleResult = options.onTimeoutError?.(method, args);
53
+ if (handleResult !== true)
54
+ throw new Error(`[birpc] timeout on calling "${method}"`);
55
+ } catch (e) {
56
+ reject(e);
57
+ }
58
+ _rpcPromiseMap.delete(id);
59
+ }, timeout);
60
+ if (typeof timeoutId === "object")
61
+ timeoutId = timeoutId.unref?.();
62
+ }
63
+ _rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
64
+ await send(newReq);
65
+ return promise;
66
+ }
67
+ try {
68
+ if (options.onRequest)
69
+ await options.onRequest(req, handler, resolve);
70
+ else
71
+ await handler();
72
+ } catch (e) {
73
+ if (options.onGeneralError?.(e) !== true)
74
+ throw e;
75
+ return;
76
+ } finally {
77
+ clearTimeout(timeoutId);
78
+ _rpcPromiseMap.delete(id);
79
+ }
80
+ return promise;
81
+ }
82
+ const $call = (method, ...args) => _call(method, args, false);
83
+ const $callOptional = (method, ...args) => _call(method, args, false, true);
84
+ const $callEvent = (method, ...args) => _call(method, args, true);
85
+ const $callRaw = (options2) => _call(options2.method, options2.args, options2.event, options2.optional);
86
+ const builtinMethods = {
87
+ $call,
88
+ $callOptional,
89
+ $callEvent,
90
+ $callRaw,
91
+ $rejectPendingCalls,
92
+ get $closed() {
93
+ return $closed;
94
+ },
95
+ $close,
96
+ $functions
97
+ };
26
98
  const rpc = new Proxy({}, {
27
99
  get(_, method) {
28
- if (method === "$functions")
29
- return functions;
30
- if (method === "$close")
31
- return close;
32
- if (method === "$rejectPendingCalls") {
33
- return rejectPendingCalls;
34
- }
35
- if (method === "$closed")
36
- return closed;
37
- if (method === "then" && !eventNames.includes("then") && !("then" in functions))
100
+ if (Object.prototype.hasOwnProperty.call(builtinMethods, method))
101
+ return builtinMethods[method];
102
+ if (method === "then" && !eventNames.includes("then") && !("then" in $functions))
38
103
  return void 0;
39
- const sendEvent = async (...args) => {
40
- await post(serialize({ m: method, a: args, t: TYPE_REQUEST }));
41
- };
104
+ const sendEvent = (...args) => _call(method, args, true);
42
105
  if (eventNames.includes(method)) {
43
106
  sendEvent.asEvent = sendEvent;
44
107
  return sendEvent;
45
108
  }
46
- const sendCall = async (...args) => {
47
- if (closed)
48
- throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
49
- if (_promiseInit) {
50
- try {
51
- await _promiseInit;
52
- } finally {
53
- _promiseInit = void 0;
54
- }
55
- }
56
- let { promise, resolve, reject } = createPromiseWithResolvers();
57
- const id = nanoid();
58
- let timeoutId;
59
- const _req = { m: method, a: args, i: id, t: TYPE_REQUEST };
60
- async function handler(req = _req) {
61
- if (timeout >= 0) {
62
- timeoutId = setTimeout(() => {
63
- try {
64
- const handleResult = options.onTimeoutError?.(method, args);
65
- if (handleResult !== true)
66
- throw new Error(`[birpc] timeout on calling "${method}"`);
67
- } catch (e) {
68
- reject(e);
69
- }
70
- rpcPromiseMap.delete(id);
71
- }, timeout);
72
- if (typeof timeoutId === "object")
73
- timeoutId = timeoutId.unref?.();
74
- }
75
- rpcPromiseMap.set(id, { resolve, reject, timeoutId, method });
76
- await post(serialize(req));
77
- return promise;
78
- }
79
- try {
80
- if (options.onRequest)
81
- await options.onRequest(_req, handler, resolve);
82
- else
83
- await handler();
84
- } catch (e) {
85
- clearTimeout(timeoutId);
86
- rpcPromiseMap.delete(id);
87
- if (options.onGeneralError?.(e) !== true)
88
- throw e;
89
- return;
90
- }
91
- return promise;
92
- };
109
+ const sendCall = (...args) => _call(method, args, false);
93
110
  sendCall.asEvent = sendEvent;
94
111
  return sendCall;
95
112
  }
96
113
  });
97
- function close(customError) {
98
- closed = true;
99
- rpcPromiseMap.forEach(({ reject, method }) => {
114
+ function $close(customError) {
115
+ $closed = true;
116
+ _rpcPromiseMap.forEach(({ reject, method }) => {
100
117
  const error = new Error(`[birpc] rpc is closed, cannot call "${method}"`);
101
118
  if (customError) {
102
119
  customError.cause ??= error;
@@ -104,18 +121,18 @@ function createBirpc(functions, options) {
104
121
  }
105
122
  reject(error);
106
123
  });
107
- rpcPromiseMap.clear();
124
+ _rpcPromiseMap.clear();
108
125
  off(onMessage);
109
126
  }
110
- function rejectPendingCalls(handler) {
111
- const entries = Array.from(rpcPromiseMap.values());
127
+ function $rejectPendingCalls(handler) {
128
+ const entries = Array.from(_rpcPromiseMap.values());
112
129
  const handlerResults = entries.map(({ method, reject }) => {
113
130
  if (!handler) {
114
131
  return reject(new Error(`[birpc]: rejected pending call "${method}".`));
115
132
  }
116
133
  return handler({ method, reject });
117
134
  });
118
- rpcPromiseMap.clear();
135
+ _rpcPromiseMap.clear();
119
136
  return handlerResults;
120
137
  }
121
138
  async function onMessage(data, ...extra) {
@@ -128,14 +145,16 @@ function createBirpc(functions, options) {
128
145
  return;
129
146
  }
130
147
  if (msg.t === TYPE_REQUEST) {
131
- const { m: method, a: args } = msg;
148
+ const { m: method, a: args, o: optional } = msg;
132
149
  let result, error;
133
- const fn = await (resolver ? resolver(method, functions[method]) : functions[method]);
150
+ let fn = await (resolver ? resolver(method, $functions[method]) : $functions[method]);
151
+ if (optional)
152
+ fn ||= () => void 0;
134
153
  if (!fn) {
135
154
  error = new Error(`[birpc] function "${method}" not found`);
136
155
  } else {
137
156
  try {
138
- result = await fn.apply(bind === "rpc" ? rpc : functions, args);
157
+ result = await fn.apply(bind === "rpc" ? rpc : $functions, args);
139
158
  } catch (e) {
140
159
  error = e;
141
160
  }
@@ -166,7 +185,7 @@ function createBirpc(functions, options) {
166
185
  }
167
186
  } else {
168
187
  const { i: ack, r: result, e: error } = msg;
169
- const promise = rpcPromiseMap.get(ack);
188
+ const promise = _rpcPromiseMap.get(ack);
170
189
  if (promise) {
171
190
  clearTimeout(promise.timeoutId);
172
191
  if (error)
@@ -174,7 +193,7 @@ function createBirpc(functions, options) {
174
193
  else
175
194
  promise.resolve(result);
176
195
  }
177
- rpcPromiseMap.delete(ack);
196
+ _rpcPromiseMap.delete(ack);
178
197
  }
179
198
  }
180
199
  _promiseInit = on(onMessage);
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
3
3
  import * as pathe from 'pathe';
4
4
  import c from 'tinyrainbow';
5
- import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.kotH7DY7.js';
5
+ import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.BYek7GgP.js';
6
6
  import { stripVTControlCharacters } from 'node:util';
7
7
  import { notNullish } from '@vitest/utils/helpers';
8
8
 
@@ -527,7 +527,6 @@ class BaseReporter {
527
527
  onInit(ctx) {
528
528
  this.ctx = ctx;
529
529
  this.ctx.logger.printBanner();
530
- this.start = performance$1.now();
531
530
  }
532
531
  log(...messages) {
533
532
  this.ctx.logger.log(...messages);
@@ -538,6 +537,10 @@ class BaseReporter {
538
537
  relative(path) {
539
538
  return relative(this.ctx.config.root, path);
540
539
  }
540
+ onTestRunStart(_specifications) {
541
+ this.start = performance$1.now();
542
+ this._timeStart = formatTimeString(/* @__PURE__ */ new Date());
543
+ }
541
544
  onTestRunEnd(testModules, unhandledErrors, _reason) {
542
545
  const files = testModules.map((testModule) => testModule.task);
543
546
  const errors = [...unhandledErrors];
@@ -712,8 +715,6 @@ class BaseReporter {
712
715
  if (this.ctx.configOverride.testNamePattern) this.log(BADGE_PADDING + c.dim(" Test name pattern: ") + c.blue(String(this.ctx.configOverride.testNamePattern)));
713
716
  this.log("");
714
717
  for (const testModule of this.failedUnwatchedFiles) this.printTestModule(testModule);
715
- this._timeStart = formatTimeString(/* @__PURE__ */ new Date());
716
- this.start = performance$1.now();
717
718
  }
718
719
  onUserConsoleLog(log, taskState) {
719
720
  if (!this.shouldLog(log, taskState)) return;
@@ -1287,6 +1288,7 @@ class DefaultReporter extends BaseReporter {
1287
1288
  if (this.renderSucceed === void 0) this.renderSucceed = !!this.renderSucceed;
1288
1289
  if (this.renderSucceed !== true) this.renderSucceed = specifications.length <= 1;
1289
1290
  }
1291
+ super.onTestRunStart(specifications);
1290
1292
  this.summary?.onTestRunStart(specifications);
1291
1293
  }
1292
1294
  onTestRunEnd(testModules, unhandledErrors, reason) {
@@ -2,7 +2,7 @@ import { resolve, isAbsolute, dirname, join } from 'node:path';
2
2
  import { existsSync } from 'node:fs';
3
3
  import 'node:module';
4
4
  import 'node:url';
5
- import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
5
+ import { g as getDefaultExportFromCjs } from './_commonjsHelpers.D26ty3Ew.js';
6
6
  import require$$0 from 'readline';
7
7
  import require$$0$1 from 'events';
8
8
 
@@ -3025,9 +3025,9 @@ var hasRequiredPrompts$2;
3025
3025
  function requirePrompts$2 () {
3026
3026
  if (hasRequiredPrompts$2) return prompts$2;
3027
3027
  hasRequiredPrompts$2 = 1;
3028
- (function (exports) {
3028
+ (function (exports$1) {
3029
3029
 
3030
- const $ = exports;
3030
+ const $ = exports$1;
3031
3031
 
3032
3032
  const el = requireElements$1();
3033
3033
 
@@ -5993,8 +5993,8 @@ var hasRequiredPrompts$1;
5993
5993
  function requirePrompts$1 () {
5994
5994
  if (hasRequiredPrompts$1) return prompts$1;
5995
5995
  hasRequiredPrompts$1 = 1;
5996
- (function (exports) {
5997
- const $ = exports;
5996
+ (function (exports$1) {
5997
+ const $ = exports$1;
5998
5998
  const el = requireElements();
5999
5999
  const noop = v => v;
6000
6000
 
@@ -1,4 +1,4 @@
1
- import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.Bgcdy3bQ.js';
1
+ import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.BiaV1qII.js';
2
2
  import { b as bench } from './benchmark.B3N2zMcH.js';
3
3
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
4
4
  import { expectTypeOf } from 'expect-type';
@@ -1,8 +1,8 @@
1
1
  import { chai } from '@vitest/expect';
2
- import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.LGjNSzXp.js';
3
- import { r as rpc } from './rpc.BUV7uWKJ.js';
2
+ import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.BOzbXE3x.js';
3
+ import { r as rpc } from './rpc.BytlcPfC.js';
4
4
  import { g as getWorkerState } from './utils.DvEY5TfP.js';
5
- import { V as VitestTestRunner, N as NodeBenchmarkRunner } from './test.ClrAtjMv.js';
5
+ import { V as VitestTestRunner, N as NodeBenchmarkRunner } from './test.BPErLMrw.js';
6
6
 
7
7
  function setupChaiConfig(config) {
8
8
  Object.assign(chai.config, config);
@@ -431,7 +431,7 @@ var jsdom = {
431
431
  NodeBlob_ = globalThis.Blob;
432
432
  NodeRequest_ = globalThis.Request;
433
433
  const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
434
- const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false,...restOptions } = jsdom;
434
+ const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false, ...restOptions } = jsdom;
435
435
  let virtualConsole;
436
436
  if (console && globalThis.console) {
437
437
  virtualConsole = new VirtualConsole();
@@ -499,7 +499,7 @@ var jsdom = {
499
499
  NodeBlob_ = globalThis.Blob;
500
500
  NodeRequest_ = globalThis.Request;
501
501
  const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
502
- const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false,...restOptions } = jsdom;
502
+ const { html = "<!DOCTYPE html>", userAgent, url = "http://localhost:3000", contentType = "text/html", pretendToBeVisual = true, includeNodeLocations = false, runScripts = "dangerously", resources, console = false, cookieJar = false, ...restOptions } = jsdom;
503
503
  let virtualConsole;
504
504
  if (console && globalThis.console) {
505
505
  virtualConsole = new VirtualConsole();
@@ -547,6 +547,9 @@ function createCompatRequest(utils) {
547
547
  super(input, compatInit);
548
548
  } else super(...args);
549
549
  }
550
+ static [Symbol.hasInstance](instance) {
551
+ return instance instanceof NodeRequest_;
552
+ }
550
553
  };
551
554
  }
552
555
  function createJSDOMCompatURL(utils) {
@@ -558,6 +561,9 @@ function createJSDOMCompatURL(utils) {
558
561
  }
559
562
  return URL.createObjectURL(blob);
560
563
  }
564
+ static [Symbol.hasInstance](instance) {
565
+ return instance instanceof URL;
566
+ }
561
567
  };
562
568
  }
563
569
  function createCompatUtils(window) {
@@ -587,7 +593,7 @@ function patchAddEventListener(window) {
587
593
  const originalAddEventListener = window.EventTarget.prototype.addEventListener;
588
594
  window.EventTarget.prototype.addEventListener = function addEventListener(type, callback, options) {
589
595
  if (typeof options === "object" && options.signal != null) {
590
- const { signal,...otherOptions } = options;
596
+ const { signal, ...otherOptions } = options;
591
597
  // - this happens because AbortSignal is provided by Node.js,
592
598
  // but jsdom APIs require jsdom's AbortSignal, while Node APIs
593
599
  // (like fetch and Request) require a Node.js AbortSignal
@@ -0,0 +1,32 @@
1
+ import { i as init } from './init.Cz2kTB9a.js';
2
+
3
+ if (!process.send) throw new Error("Expected worker to be run in node:child_process");
4
+ // Store globals in case tests overwrite them
5
+ const processExit = process.exit.bind(process);
6
+ const processSend = process.send.bind(process);
7
+ const processOn = process.on.bind(process);
8
+ const processOff = process.off.bind(process);
9
+ const processRemoveAllListeners = process.removeAllListeners.bind(process);
10
+ // Work-around for nodejs/node#55094
11
+ if (process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"))) processOn("SIGTERM", () => processExit());
12
+ function workerInit(options) {
13
+ const { runTests } = options;
14
+ init({
15
+ post: (v) => processSend(v),
16
+ on: (cb) => processOn("message", cb),
17
+ off: (cb) => processOff("message", cb),
18
+ teardown: () => processRemoveAllListeners("message"),
19
+ runTests: (state) => executeTests("run", state),
20
+ collectTests: (state) => executeTests("collect", state),
21
+ setup: options.setup
22
+ });
23
+ async function executeTests(method, state) {
24
+ try {
25
+ await runTests(method, state);
26
+ } finally {
27
+ process.exit = processExit;
28
+ }
29
+ }
30
+ }
31
+
32
+ export { workerInit as w };
@@ -1,5 +1,5 @@
1
1
  import { isMainThread, parentPort } from 'node:worker_threads';
2
- import { i as init } from './init.DMDG-idf.js';
2
+ import { i as init } from './init.Cz2kTB9a.js';
3
3
 
4
4
  if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
5
5
  function workerInit(options) {
@@ -3,10 +3,10 @@ import { isBuiltin } from 'node:module';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { resolve } from 'pathe';
5
5
  import { ModuleRunner } from 'vite/module-runner';
6
- import { b as VitestTransport } from './startModuleRunner.BOmUtLIO.js';
7
- import { e as environments } from './index.DfKyPFVi.js';
6
+ import { b as VitestTransport } from './startModuleRunner.DLjmA_wU.js';
7
+ import { e as environments } from './index.QWbK7rHY.js';
8
8
  import { serializeError } from '@vitest/utils/error';
9
- import { o as onCancel, a as rpcDone, c as createRuntimeRpc } from './rpc.BUV7uWKJ.js';
9
+ import { o as onCancel, a as rpcDone, c as createRuntimeRpc } from './rpc.BytlcPfC.js';
10
10
  import { createStackString, parseStacktrace } from '@vitest/utils/source-map';
11
11
  import { s as setupInspect } from './inspector.CvyFGlXm.js';
12
12
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
@@ -2,7 +2,7 @@ import * as _vitest_spy from '@vitest/spy';
2
2
  import vm from 'node:vm';
3
3
  import * as viteModuleRunner from 'vite/module-runner';
4
4
  import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode, FetchFunction, EvaluatedModules } from 'vite/module-runner';
5
- import { R as RuntimeRPC, e as ResolveFunctionResult, W as WorkerGlobalState } from './worker.d.DadbA89M.js';
5
+ import { R as RuntimeRPC, e as ResolveFunctionResult, W as WorkerGlobalState } from './worker.d.ZGohxCEd.js';
6
6
  import { MockedModule, MockedModuleType } from '@vitest/mocker';
7
7
  import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './mocker.d.BE_2ls6u.js';
8
8
 
@@ -1,4 +1,4 @@
1
- import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.Da1D1VbQ.js';
1
+ import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.keG-yFSu.js';
2
2
 
3
3
  interface VitestPluginContext {
4
4
  vitest: Vitest;
@@ -1,13 +1,13 @@
1
1
  import { TaskMeta, Suite, File, TestAnnotation, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
2
2
  import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
3
- import { A as AfterSuiteRunMeta, U as UserConsoleLog, P as ProvidedContext, d as ContextTestEnvironment, f as WorkerTestEnvironment, g as WorkerExecuteContext, L as LabelColor } from './worker.d.DadbA89M.js';
3
+ import { A as AfterSuiteRunMeta, U as UserConsoleLog, P as ProvidedContext, d as ContextTestEnvironment, f as WorkerTestEnvironment, g as WorkerExecuteContext, L as LabelColor } from './worker.d.ZGohxCEd.js';
4
4
  import { Writable } from 'node:stream';
5
5
  import { TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
6
  import { MockedModule } from '@vitest/mocker';
7
7
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
8
8
  import { BrowserCommands } from 'vitest/browser';
9
9
  import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.BTfZNUu9.js';
10
- import { S as SerializedTestSpecification, B as BrowserTesterOptions } from './browser.d.DTTM2PTh.js';
10
+ import { S as SerializedTestSpecification, B as BrowserTesterOptions } from './browser.d.DnU_kh8a.js';
11
11
  import { PrettyFormatOptions } from '@vitest/pretty-format';
12
12
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
13
13
  import { SerializedDiffOptions } from '@vitest/utils/diff';
@@ -1325,7 +1325,7 @@ declare class Vitest {
1325
1325
  /**
1326
1326
  * Register a handler that will be called when the test run is cancelled with `vitest.cancelCurrentRun`.
1327
1327
  */
1328
- onCancel(fn: (reason: CancelReason) => Awaitable<void>): void;
1328
+ onCancel(fn: (reason: CancelReason) => Awaitable<void>): () => void;
1329
1329
  /**
1330
1330
  * Register a handler that will be called when the server is closed.
1331
1331
  */
@@ -1965,6 +1965,7 @@ declare abstract class BaseReporter implements Reporter {
1965
1965
  log(...messages: any): void;
1966
1966
  error(...messages: any): void;
1967
1967
  relative(path: string): string;
1968
+ onTestRunStart(_specifications: ReadonlyArray<TestSpecification>): void;
1968
1969
  onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, _reason: TestRunEndReason): void;
1969
1970
  onTestCaseResult(testCase: TestCase): void;
1970
1971
  onTestSuiteResult(testSuite: TestSuite): void;
@@ -1,5 +1,5 @@
1
1
  import { getSafeTimers } from '@vitest/utils/timers';
2
- import { c as createBirpc } from './index.DAL392Ss.js';
2
+ import { c as createBirpc } from './index.0kCJoeWi.js';
3
3
  import { g as getWorkerState } from './utils.DvEY5TfP.js';
4
4
 
5
5
  const { get } = Reflect;
@@ -26,7 +26,7 @@ async function setupCommonEnv(config) {
26
26
  if (globalSetup) return;
27
27
  globalSetup = true;
28
28
  setSafeTimers();
29
- if (config.globals) (await import('./globals.DOh96BiR.js')).registerApiGlobally();
29
+ if (config.globals) (await import('./globals.NLOzC_A5.js')).registerApiGlobally();
30
30
  }
31
31
  function setupDefines(config) {
32
32
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -34,7 +34,7 @@ function setupDefines(config) {
34
34
  function setupEnv(env) {
35
35
  const state = getWorkerState();
36
36
  // same boolean-to-string assignment as VitestPlugin.configResolved
37
- const { PROD, DEV,...restEnvs } = env;
37
+ const { PROD, DEV, ...restEnvs } = env;
38
38
  state.metaEnv.PROD = PROD;
39
39
  state.metaEnv.DEV = DEV;
40
40
  for (const key in restEnvs) state.metaEnv[key] = env[key];
@@ -351,8 +351,8 @@ class VitestMocker {
351
351
  async callFunctionMock(id, url, mock) {
352
352
  const node = this.ensureModule(id, url);
353
353
  if (node.exports) return node.exports;
354
- const exports = await mock.resolve();
355
- const moduleExports = new Proxy(exports, { get: (target, prop) => {
354
+ const exports$1 = await mock.resolve();
355
+ const moduleExports = new Proxy(exports$1, { get: (target, prop) => {
356
356
  const val = target[prop];
357
357
  // 'then' can exist on non-Promise objects, need nested instanceof check for logic to work
358
358
  if (prop === "then") {
@@ -444,8 +444,8 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
444
444
  const Object = this.primitives.Object;
445
445
  // we have to define a separate object that will copy all properties into itself
446
446
  // and can't just use the same `exports` define automatically by Vite before the evaluator
447
- const exports = Object.create(null);
448
- Object.defineProperty(exports, Symbol.toStringTag, {
447
+ const exports$1 = Object.create(null);
448
+ Object.defineProperty(exports$1, Symbol.toStringTag, {
449
449
  value: "Module",
450
450
  configurable: true,
451
451
  writable: true
@@ -453,10 +453,10 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
453
453
  const node = this.ensureModule(mockId, this.getMockPath(evaluatedNode.url));
454
454
  node.meta = evaluatedNode.meta;
455
455
  node.file = evaluatedNode.file;
456
- node.mockedExports = exports;
456
+ node.mockedExports = exports$1;
457
457
  const mod = await this.moduleRunner.cachedRequest(url, node, callstack, void 0, true);
458
- this.mockObject(mod, exports, mock.type);
459
- return exports;
458
+ this.mockObject(mod, exports$1, mock.type);
459
+ return exports$1;
460
460
  }
461
461
  if (mock.type === "manual" && !callstack.includes(mockId) && !callstack.includes(url)) try {
462
462
  callstack.push(mockId);
@@ -595,8 +595,8 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
595
595
  * We should keep the Vite behavour when there is a `strict` flag.
596
596
  * @internal
597
597
  */
598
- processImport(exports) {
599
- return exports;
598
+ processImport(exports$1) {
599
+ return exports$1;
600
600
  }
601
601
  async import(rawId) {
602
602
  const resolved = await this.vitestOptions.transport.resolveId(rawId);
@@ -7,8 +7,8 @@ import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
7
7
  import { getTests, getNames, getTestName } from '@vitest/runner/utils';
8
8
  import { processError } from '@vitest/utils/error';
9
9
  import { normalize } from 'pathe';
10
- import { a as getSnapshotClient, i as inject, c as createExpect, v as vi } from './vi.Bgcdy3bQ.js';
11
- import { r as rpc } from './rpc.BUV7uWKJ.js';
10
+ import { a as getSnapshotClient, i as inject, c as createExpect, v as vi } from './vi.BiaV1qII.js';
11
+ import { r as rpc } from './rpc.BytlcPfC.js';
12
12
 
13
13
  function createBenchmarkResult(name) {
14
14
  return {
@@ -9,7 +9,7 @@ import { assertTypes, createSimpleStackTrace } from '@vitest/utils/helpers';
9
9
  import { fn, spyOn, restoreAllMocks, resetAllMocks, clearAllMocks, isMockFunction } from '@vitest/spy';
10
10
  import '@vitest/utils/offset';
11
11
  import { parseSingleStack } from '@vitest/utils/source-map';
12
- import { c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
12
+ import { c as commonjsGlobal } from './_commonjsHelpers.D26ty3Ew.js';
13
13
  import { R as RealDate, r as resetDate, m as mockDate } from './date.Bq6ZW5rf.js';
14
14
 
15
15
  // these matchers are not supported because they don't make sense with poll
@@ -584,7 +584,7 @@ var hasRequiredDeprecated;
584
584
  function requireDeprecated () {
585
585
  if (hasRequiredDeprecated) return deprecated;
586
586
  hasRequiredDeprecated = 1;
587
- (function (exports) {
587
+ (function (exports$1) {
588
588
 
589
589
  /**
590
590
  * Returns a function that will invoke the supplied function and print a
@@ -593,9 +593,9 @@ function requireDeprecated () {
593
593
  * @param {string} msg
594
594
  * @returns {Function}
595
595
  */
596
- exports.wrap = function (func, msg) {
596
+ exports$1.wrap = function (func, msg) {
597
597
  var wrapped = function () {
598
- exports.printWarning(msg);
598
+ exports$1.printWarning(msg);
599
599
  return func.apply(this, arguments);
600
600
  };
601
601
  if (func.prototype) {
@@ -611,7 +611,7 @@ function requireDeprecated () {
611
611
  * @param {string} funcName
612
612
  * @returns {string}
613
613
  */
614
- exports.defaultMsg = function (packageName, funcName) {
614
+ exports$1.defaultMsg = function (packageName, funcName) {
615
615
  return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
616
616
  };
617
617
 
@@ -620,7 +620,7 @@ function requireDeprecated () {
620
620
  * @param {string} msg
621
621
  * @returns {undefined}
622
622
  */
623
- exports.printWarning = function (msg) {
623
+ exports$1.printWarning = function (msg) {
624
624
  /* istanbul ignore next */
625
625
  if (typeof process === "object" && process.emitWarning) {
626
626
  // Emit Warnings in Node
@@ -839,7 +839,7 @@ var hasRequiredTypeDetect;
839
839
  function requireTypeDetect () {
840
840
  if (hasRequiredTypeDetect) return typeDetect$1.exports;
841
841
  hasRequiredTypeDetect = 1;
842
- (function (module, exports) {
842
+ (function (module, exports$1) {
843
843
  (function (global, factory) {
844
844
  module.exports = factory() ;
845
845
  }(typeDetect, (function () {
@@ -3902,7 +3902,7 @@ function _mocker() {
3902
3902
  function getImporter(name) {
3903
3903
  const stackArray = createSimpleStackTrace({ stackTraceLimit: 5 }).split("\n");
3904
3904
  return parseSingleStack(stackArray[stackArray.findLastIndex((stack) => {
3905
- return stack.includes(` at Object.${name}`) || stack.includes(`${name}@`);
3905
+ return stack.includes(` at Object.${name}`) || stack.includes(`${name}@`) || stack.includes(` at ${name} (`);
3906
3906
  }) + 1])?.file || "";
3907
3907
  }
3908
3908