vitest 2.0.4 → 2.1.0-beta.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 (80) hide show
  1. package/dist/browser.d.ts +21 -42
  2. package/dist/browser.js +5 -5
  3. package/dist/chunks/RandomSequencer.B4M2ux5b.js +952 -0
  4. package/dist/{vendor/base.DRHPZCCj.js → chunks/base.BH-FAiX7.js} +2 -2
  5. package/dist/{vendor/base.Csk7BT3h.js → chunks/base.BYvKfYzm.js} +3 -3
  6. package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.C8CRJYG4.js} +1 -1
  7. package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
  8. package/dist/{vendor/cac.DFtWvZc2.js → chunks/cac.CaYKA7Wt.js} +19 -21
  9. package/dist/{vendor/cli-api.CTkP2Ier.js → chunks/cli-api.B8LE391_.js} +500 -4615
  10. package/dist/chunks/config.CHuotKvS.d.ts +206 -0
  11. package/dist/chunks/{runtime-console.C2L2zykk.js → console.DI3gHgtH.js} +11 -14
  12. package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
  13. package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
  14. package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.GreKbaUc.js} +10 -11
  15. package/dist/chunks/env.CmHVDJnw.js +7 -0
  16. package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
  17. package/dist/{vendor/execute.jzOWtys_.js → chunks/execute.DT9BA6zp.js} +28 -20
  18. package/dist/chunks/globals.DRPLtPOv.js +31 -0
  19. package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
  20. package/dist/{vendor/index.DI9daj1Q.js → chunks/index.CNZXZ9PJ.js} +43 -43
  21. package/dist/{vendor/index.BJmtb_7W.js → chunks/index.CxRxs566.js} +2 -2
  22. package/dist/{vendor/index.CVqMv71L.js → chunks/index.CxWPpGJz.js} +11 -12
  23. package/dist/{vendor/index.CuuL9y4g.js → chunks/index.YuPJueCg.js} +505 -1185
  24. package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
  25. package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
  26. package/dist/chunks/{environments-node.XE5FbRPQ.js → node.Bx4JZjMG.js} +2 -2
  27. package/dist/{reporters-B7ebVMkT.d.ts → chunks/reporters.DRZ7ndzr.d.ts} +860 -1000
  28. package/dist/chunks/resolveConfig.CGobt8AB.js +8120 -0
  29. package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
  30. package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
  31. package/dist/chunks/{runtime-runBaseTests.Dq_sJZq9.js → runBaseTests.BAhL8UH_.js} +21 -23
  32. package/dist/{vendor/setup-common.symvFZPh.js → chunks/setup-common.KBrCO5LJ.js} +2 -2
  33. package/dist/{suite-CRLAhsm0.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
  34. package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
  35. package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
  36. package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
  37. package/dist/{vendor/utils.BySfPUwy.js → chunks/utils.DO38lwfj.js} +8 -21
  38. package/dist/{vendor/vi.Elqer9-7.js → chunks/vi.B6QZ938s.js} +13 -18
  39. package/dist/{vendor/vm.img-AOox.js → chunks/vm.kl9T_5ai.js} +40 -68
  40. package/dist/chunks/worker.BANO5ak1.d.ts +144 -0
  41. package/dist/chunks/worker.Cx2xE71X.d.ts +8 -0
  42. package/dist/cli.js +3 -3
  43. package/dist/config.cjs +6 -8
  44. package/dist/config.d.ts +10 -8
  45. package/dist/config.js +6 -8
  46. package/dist/coverage.d.ts +10 -8
  47. package/dist/coverage.js +35 -15
  48. package/dist/environments.d.ts +3 -19
  49. package/dist/environments.js +1 -1
  50. package/dist/execute.d.ts +5 -14
  51. package/dist/execute.js +2 -2
  52. package/dist/index.d.ts +267 -34
  53. package/dist/index.js +12 -12
  54. package/dist/node.d.ts +15 -9
  55. package/dist/node.js +26 -28
  56. package/dist/reporters.d.ts +10 -8
  57. package/dist/reporters.js +16 -18
  58. package/dist/runners.d.ts +15 -20
  59. package/dist/runners.js +12 -13
  60. package/dist/snapshot.js +3 -3
  61. package/dist/suite.d.ts +2 -16
  62. package/dist/suite.js +4 -4
  63. package/dist/worker.js +7 -8
  64. package/dist/workers/forks.js +5 -5
  65. package/dist/workers/runVmTests.js +18 -19
  66. package/dist/workers/threads.js +5 -5
  67. package/dist/workers/vmForks.js +8 -8
  68. package/dist/workers/vmThreads.js +8 -8
  69. package/dist/workers.d.ts +13 -8
  70. package/dist/workers.js +13 -13
  71. package/package.json +16 -17
  72. package/dist/chunks/integrations-globals.nDMtdOcn.js +0 -31
  73. package/dist/vendor/env.2ltrQNq0.js +0 -8
  74. package/dist/vendor/index.BMmMjLIQ.js +0 -3975
  75. /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
  76. /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
  77. /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
  78. /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
  79. /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
  80. /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
@@ -7,7 +7,7 @@ import { resolve, isAbsolute, dirname, join, basename, extname, normalize, relat
7
7
  import { processError } from '@vitest/utils/error';
8
8
  import { distDir } from '../path.js';
9
9
  import { highlight, getType } from '@vitest/utils';
10
- import { g as getAllMockableProperties } from './base.DRHPZCCj.js';
10
+ import { g as getAllMockableProperties } from './base.BH-FAiX7.js';
11
11
 
12
12
  const { existsSync, readdirSync } = fs;
13
13
  const spyModulePath = resolve(distDir, "spy.js");
@@ -136,7 +136,7 @@ class VitestMocker {
136
136
  return {
137
137
  id,
138
138
  fsPath,
139
- external
139
+ external: external ? this.normalizePath(external) : external
140
140
  };
141
141
  }
142
142
  async resolveMocks() {
@@ -160,8 +160,7 @@ class VitestMocker {
160
160
  VitestMocker.pendingIds = [];
161
161
  }
162
162
  async callFunctionMock(dep, mock) {
163
- var _a, _b;
164
- const cached = (_a = this.moduleCache.get(dep)) == null ? void 0 : _a.exports;
163
+ const cached = this.moduleCache.get(dep)?.exports;
165
164
  if (cached) {
166
165
  return cached;
167
166
  }
@@ -176,7 +175,7 @@ class VitestMocker {
176
175
  throw vitestError;
177
176
  }
178
177
  const filepath = dep.slice(5);
179
- const mockpath = ((_b = this.resolveCache.get(this.getSuiteFilepath())) == null ? void 0 : _b[filepath]) || filepath;
178
+ const mockpath = this.resolveCache.get(this.getSuiteFilepath())?.[filepath] || filepath;
180
179
  if (exports === null || typeof exports !== "object") {
181
180
  throw this.createError(
182
181
  `[vitest] vi.mock("${mockpath}", factory?: () => unknown) is not returning an object. Did you mean to return an object with a "default" key?`
@@ -229,20 +228,31 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
229
228
  resolveMockPath(mockPath, external) {
230
229
  const path = external || mockPath;
231
230
  if (external || isNodeBuiltin(mockPath) || !existsSync(mockPath)) {
231
+ let findFile2 = function(mockFolder2, baseOriginal2) {
232
+ const files = readdirSync(mockFolder2);
233
+ for (const file of files) {
234
+ const baseFile = basename(file, extname(file));
235
+ if (baseFile === baseOriginal2) {
236
+ const path2 = resolve(mockFolder2, file);
237
+ if (fs.statSync(path2).isFile()) {
238
+ return path2;
239
+ } else {
240
+ const indexFile = findFile2(path2, "index");
241
+ if (indexFile) {
242
+ return indexFile;
243
+ }
244
+ }
245
+ }
246
+ }
247
+ return null;
248
+ };
232
249
  const mockDirname = dirname(path);
233
250
  const mockFolder = join(this.root, "__mocks__", mockDirname);
234
251
  if (!existsSync(mockFolder)) {
235
252
  return null;
236
253
  }
237
- const files = readdirSync(mockFolder);
238
254
  const baseOriginal = basename(path);
239
- for (const file of files) {
240
- const baseFile = basename(file, extname(file));
241
- if (baseFile === baseOriginal) {
242
- return resolve(mockFolder, file);
243
- }
244
- }
245
- return null;
255
+ return findFile2(mockFolder, baseOriginal);
246
256
  }
247
257
  const dir = dirname(path);
248
258
  const baseId = basename(path);
@@ -365,7 +375,7 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
365
375
  const suitefile = this.getSuiteFilepath();
366
376
  const mocks = this.mockMap.get(suitefile) || {};
367
377
  const resolves = this.resolveCache.get(suitefile) || {};
368
- mocks[id] = factory || this.resolveMockPath(path, external);
378
+ mocks[id] = factory || this.resolveMockPath(id, external);
369
379
  resolves[id] = originalId;
370
380
  this.mockMap.set(suitefile, mocks);
371
381
  this.resolveCache.set(suitefile, resolves);
@@ -385,7 +395,7 @@ If you need to partially mock a module, you can use "importOriginal" helper insi
385
395
  const normalizedId = this.normalizePath(fsPath);
386
396
  let mock = this.getDependencyMock(normalizedId);
387
397
  if (mock === void 0) {
388
- mock = this.resolveMockPath(fsPath, external);
398
+ mock = this.resolveMockPath(normalizedId, external);
389
399
  }
390
400
  if (mock === null) {
391
401
  const mod = await this.executor.cachedRequest(id, fsPath, [importee]);
@@ -459,7 +469,6 @@ function listenForErrors(state) {
459
469
  dispose.forEach((fn) => fn());
460
470
  dispose.length = 0;
461
471
  function catchError(err, type, event) {
462
- var _a;
463
472
  const worker = state();
464
473
  if (worker.current) {
465
474
  const listeners = process.listeners(event);
@@ -469,7 +478,7 @@ function listenForErrors(state) {
469
478
  }
470
479
  const error = processError(err);
471
480
  if (!isPrimitive(error)) {
472
- error.VITEST_TEST_NAME = (_a = worker.current) == null ? void 0 : _a.name;
481
+ error.VITEST_TEST_NAME = worker.current?.name;
473
482
  if (worker.filepath) {
474
483
  error.VITEST_TEST_PATH = relative(state().config.root, worker.filepath);
475
484
  }
@@ -559,7 +568,7 @@ function updateStyle(id, css) {
559
568
  style.setAttribute("type", "text/css");
560
569
  style.setAttribute("data-vite-dev-id", id);
561
570
  style.textContent = css;
562
- head == null ? void 0 : head.appendChild(style);
571
+ head?.appendChild(style);
563
572
  }
564
573
  function removeStyle(id) {
565
574
  if (typeof document === "undefined") {
@@ -629,11 +638,10 @@ class VitestExecutor extends ViteNodeRunner {
629
638
  return globalThis.__vitest_worker__ || this.options.state;
630
639
  }
631
640
  shouldResolveId(id, _importee) {
632
- var _a;
633
641
  if (isInternalRequest(id) || id.startsWith("data:")) {
634
642
  return false;
635
643
  }
636
- const transformMode = ((_a = this.state.environment) == null ? void 0 : _a.transformMode) ?? "ssr";
644
+ const transformMode = this.state.environment?.transformMode ?? "ssr";
637
645
  return transformMode === "ssr" ? !isNodeBuiltin(id) : !id.startsWith("node:");
638
646
  }
639
647
  async originalResolveUrl(id, importer) {
@@ -0,0 +1,31 @@
1
+ import { g as globalApis } from './constants.CaAN7icJ.js';
2
+ import { V as VitestIndex } from './index.CNZXZ9PJ.js';
3
+ import '@vitest/runner';
4
+ import './benchmark.C8CRJYG4.js';
5
+ import '@vitest/runner/utils';
6
+ import '@vitest/utils';
7
+ import './index.CxRxs566.js';
8
+ import 'pathe';
9
+ import './utils.Ck2hJTRs.js';
10
+ import './env.CmHVDJnw.js';
11
+ import 'std-env';
12
+ import './run-once.Sxe67Wng.js';
13
+ import './vi.B6QZ938s.js';
14
+ import 'chai';
15
+ import './_commonjsHelpers.BFTU3MAI.js';
16
+ import '@vitest/expect';
17
+ import '@vitest/snapshot';
18
+ import '@vitest/utils/error';
19
+ import './tasks.BZnCS9aT.js';
20
+ import '@vitest/utils/source-map';
21
+ import './base.BH-FAiX7.js';
22
+ import './date.W2xKR2qe.js';
23
+ import '@vitest/spy';
24
+
25
+ function registerApiGlobally() {
26
+ globalApis.forEach((api) => {
27
+ globalThis[api] = VitestIndex[api];
28
+ });
29
+ }
30
+
31
+ export { registerApiGlobally };
@@ -546,7 +546,7 @@ function requireClear$1 () {
546
546
  if (hasRequiredClear$1) return clear$1;
547
547
  hasRequiredClear$1 = 1;
548
548
 
549
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
549
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
550
550
 
551
551
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
552
552
 
@@ -3505,7 +3505,7 @@ function requireDist () {
3505
3505
 
3506
3506
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3507
3507
 
3508
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3508
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3509
3509
 
3510
3510
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3511
3511
 
@@ -1,23 +1,11 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
- import { b as bench } from './benchmark.B6pblCp2.js';
3
- import { i as isFirstRun, a as runOnce } from './run-once.Db8Hgq9X.js';
4
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.Elqer9-7.js';
5
- import { g as getWorkerState } from './global.7bFbnyXl.js';
2
+ import { b as bench } from './benchmark.C8CRJYG4.js';
3
+ import { i as isFirstRun, a as runOnce } from './run-once.Sxe67Wng.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.B6QZ938s.js';
5
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
6
6
  import * as chai from 'chai';
7
7
  import { assert, should } from 'chai';
8
8
 
9
- function getRunningMode() {
10
- return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
11
- }
12
- function isWatchMode() {
13
- return getRunningMode() === "watch";
14
- }
15
-
16
- function inject(key) {
17
- const workerState = getWorkerState();
18
- return workerState.providedContext[key];
19
- }
20
-
21
9
  var dist = {};
22
10
 
23
11
  (function (exports) {
@@ -99,33 +87,45 @@ function noop() {
99
87
  }
100
88
  const assertType = noop;
101
89
 
90
+ function getRunningMode() {
91
+ return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
92
+ }
93
+ function isWatchMode() {
94
+ return getRunningMode() === "watch";
95
+ }
96
+
97
+ function inject(key) {
98
+ const workerState = getWorkerState();
99
+ return workerState.providedContext[key];
100
+ }
101
+
102
102
  var VitestIndex = /*#__PURE__*/Object.freeze({
103
- __proto__: null,
104
- afterAll: afterAll,
105
- afterEach: afterEach,
106
- assert: assert,
107
- assertType: assertType,
108
- beforeAll: beforeAll,
109
- beforeEach: beforeEach,
110
- bench: bench,
111
- chai: chai,
112
- createExpect: createExpect,
113
- describe: describe,
114
- expect: globalExpect,
115
- expectTypeOf: dist.expectTypeOf,
116
- getRunningMode: getRunningMode,
117
- inject: inject,
118
- isFirstRun: isFirstRun,
119
- isWatchMode: isWatchMode,
120
- it: it,
121
- onTestFailed: onTestFailed,
122
- onTestFinished: onTestFinished,
123
- runOnce: runOnce,
124
- should: should,
125
- suite: suite,
126
- test: test,
127
- vi: vi,
128
- vitest: vitest
103
+ __proto__: null,
104
+ afterAll: afterAll,
105
+ afterEach: afterEach,
106
+ assert: assert,
107
+ assertType: assertType,
108
+ beforeAll: beforeAll,
109
+ beforeEach: beforeEach,
110
+ bench: bench,
111
+ chai: chai,
112
+ createExpect: createExpect,
113
+ describe: describe,
114
+ expect: globalExpect,
115
+ expectTypeOf: dist.expectTypeOf,
116
+ getRunningMode: getRunningMode,
117
+ inject: inject,
118
+ isFirstRun: isFirstRun,
119
+ isWatchMode: isWatchMode,
120
+ it: it,
121
+ onTestFailed: onTestFailed,
122
+ onTestFinished: onTestFinished,
123
+ runOnce: runOnce,
124
+ should: should,
125
+ suite: suite,
126
+ test: test,
127
+ vi: vi,
128
+ vitest: vitest
129
129
  });
130
130
 
131
- export { VitestIndex as V, isWatchMode as a, assertType as b, dist as d, getRunningMode as g, inject as i };
131
+ export { VitestIndex as V, assertType as a, inject as b, dist as d, getRunningMode as g, isWatchMode as i };
@@ -1,8 +1,8 @@
1
1
  import { relative } from 'pathe';
2
2
  import '@vitest/runner/utils';
3
3
  import '@vitest/utils';
4
- import { g as getWorkerState } from './global.7bFbnyXl.js';
5
- import './env.2ltrQNq0.js';
4
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
5
+ import './env.CmHVDJnw.js';
6
6
 
7
7
  function getRunMode() {
8
8
  return getWorkerState().config.mode;
@@ -1,10 +1,10 @@
1
1
  import * as chai from 'chai';
2
2
  import { resolve } from 'pathe';
3
3
  import { distDir } from '../path.js';
4
- import { g as getWorkerState } from './global.7bFbnyXl.js';
5
- import { r as rpc } from './rpc.BGx7q_k2.js';
6
- import { t as takeCoverageInsideWorker } from './coverage.BhYSDdTT.js';
7
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.symvFZPh.js';
4
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
5
+ import { r as rpc } from './rpc.B7Mfb-Yf.js';
6
+ import { t as takeCoverageInsideWorker } from './coverage.CqfT4xaf.js';
7
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.KBrCO5LJ.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);
@@ -12,7 +12,7 @@ function setupChaiConfig(config) {
12
12
 
13
13
  async function resolveSnapshotEnvironment(config, executor) {
14
14
  if (!config.snapshotEnvironment) {
15
- const { VitestNodeSnapshotEnvironment } = await import('../chunks/environments-node.XE5FbRPQ.js');
15
+ const { VitestNodeSnapshotEnvironment } = await import('./node.Bx4JZjMG.js');
16
16
  return new VitestNodeSnapshotEnvironment();
17
17
  }
18
18
  const mod = await executor.executeId(config.snapshotEnvironment);
@@ -60,7 +60,7 @@ async function resolveTestRunner(config, executor) {
60
60
  const originalOnTaskUpdate = testRunner.onTaskUpdate;
61
61
  testRunner.onTaskUpdate = async (task) => {
62
62
  const p = rpc().onTaskUpdate(task);
63
- await (originalOnTaskUpdate == null ? void 0 : originalOnTaskUpdate.call(testRunner, task));
63
+ await originalOnTaskUpdate?.call(testRunner, task);
64
64
  return p;
65
65
  };
66
66
  const originalOnCollected = testRunner.onCollected;
@@ -73,7 +73,7 @@ async function resolveTestRunner(config, executor) {
73
73
  state.durations.environment = 0;
74
74
  });
75
75
  rpc().onCollected(files);
76
- await (originalOnCollected == null ? void 0 : originalOnCollected.call(testRunner, files));
76
+ await originalOnCollected?.call(testRunner, files);
77
77
  };
78
78
  const originalOnAfterRun = testRunner.onAfterRunFiles;
79
79
  testRunner.onAfterRunFiles = async (files) => {
@@ -86,20 +86,19 @@ async function resolveTestRunner(config, executor) {
86
86
  projectName: state.ctx.projectName
87
87
  });
88
88
  }
89
- await (originalOnAfterRun == null ? void 0 : originalOnAfterRun.call(testRunner, files));
89
+ await originalOnAfterRun?.call(testRunner, files);
90
90
  };
91
91
  const originalOnAfterRunTask = testRunner.onAfterRunTask;
92
92
  testRunner.onAfterRunTask = async (test) => {
93
- var _a, _b;
94
- if (config.bail && ((_a = test.result) == null ? void 0 : _a.state) === "fail") {
93
+ if (config.bail && test.result?.state === "fail") {
95
94
  const previousFailures = await rpc().getCountOfFailedTests();
96
95
  const currentFailures = 1 + previousFailures;
97
96
  if (currentFailures >= config.bail) {
98
97
  rpc().onCancel("test-failure");
99
- (_b = testRunner.onCancel) == null ? void 0 : _b.call(testRunner, "test-failure");
98
+ testRunner.onCancel?.("test-failure");
100
99
  }
101
100
  }
102
- await (originalOnAfterRunTask == null ? void 0 : originalOnAfterRunTask.call(testRunner, test));
101
+ await originalOnAfterRunTask?.call(testRunner, test);
103
102
  };
104
103
  return testRunner;
105
104
  }