vitest 5.0.2 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE.md +29 -1
  2. package/browser/context.d.ts +7 -1
  3. package/browser/context.js +5 -5
  4. package/dist/browser.d.ts +4 -4
  5. package/dist/browser.js +11 -11
  6. package/dist/chunks/{base.5tQXSzMP.js → base.CYbb9pQW.js} +39 -15
  7. package/dist/chunks/{browser.d.g5Thl309.d.ts → browser.d.FGQ9_rK6.d.ts} +3 -3
  8. package/dist/chunks/{cac.BLbEtnDd.js → cac.DTXWs6Ni.js} +21 -23
  9. package/dist/chunks/cli-api.Bx28WXzL.js +13879 -0
  10. package/dist/chunks/{config.d.CU_b-wJj.d.ts → config.d.QBNYCgFU.d.ts} +33 -24
  11. package/dist/chunks/{console.B09ye7y0.js → console.DtI4yxfN.js} +5 -4
  12. package/dist/chunks/{coverage.AipniaqB.js → coverage.-bm5IxnW.js} +1 -1
  13. package/dist/chunks/{coverage.CX7NN5s7.js → coverage.cTDc4uSS.js} +1 -1
  14. package/dist/chunks/{creator.2VTnpYzN.js → creator.CLL8QFMS.js} +44 -54
  15. package/dist/chunks/{defaults.D2ip7f-X.js → defaults.B1FCaFfh.js} +2 -2
  16. package/dist/chunks/{display.pkpxlVcY.js → display.BlTmubjj.js} +1 -1
  17. package/dist/chunks/{doctor.BCXa6-1R.js → doctor.Bqc8NDDb.js} +40 -41
  18. package/dist/chunks/{env.DzFJjrmK.js → env.BKKtU2WC.js} +1 -1
  19. package/dist/chunks/{environment.d.C6xYahWA.d.ts → environment.d.BY56MoGs.d.ts} +1 -1
  20. package/dist/chunks/{globals.Brdv9iOs.js → globals.CTWMSIPL.js} +10 -10
  21. package/dist/chunks/{index.C-uw7tH9.js → index.B8VfM7Mf.js} +8606 -20822
  22. package/dist/chunks/{index.DXQx-kDM.js → index.BoyTG_B7.js} +9 -4
  23. package/dist/chunks/{index.hTNFpC24.js → index.CPNMO3h-.js} +73 -50
  24. package/dist/chunks/{index.M2dsQ_UQ.js → index.D0heQG4v.js} +557 -183
  25. package/dist/chunks/{index.BgwtGYxD.js → index.GYMZ12wH.js} +5 -5
  26. package/dist/chunks/{index.DGdajAO2.js → index.uwTEEBsB.js} +94 -71
  27. package/dist/chunks/{init-forks.CdGu3HUy.js → init-forks.CbYYa5xq.js} +1 -1
  28. package/dist/chunks/{init-threads.2f_lsHNK.js → init-threads.DtjdvxPl.js} +1 -1
  29. package/dist/chunks/{init.IsjtLXKe.js → init.DrHtV5zd.js} +7 -7
  30. package/dist/chunks/module-dependencies.CwNPkcV4.js +71 -0
  31. package/dist/chunks/{native.CF4uT5hY.js → native.cdzHIdmv.js} +48 -34
  32. package/dist/chunks/{nativeModuleMocker.DwRB4F9R.js → nativeModuleMocker.D8f4cW4A.js} +2 -2
  33. package/dist/chunks/{nativeModuleRunner.J0QLzNtK.js → nativeModuleRunner.xi64Afb2.js} +1 -1
  34. package/dist/chunks/{node.CfQ_OGWr.js → node.uQulW0ei.js} +1 -1
  35. package/dist/chunks/{pathe.M-eThtNZ.DwEga6ro.js → pathe.M-eThtNZ.Ba-7h1rE.js} +9 -7
  36. package/dist/chunks/{plugin.d.My_z-jmU.d.ts → plugin.d.C8mmycim.d.ts} +109 -68
  37. package/dist/chunks/{plugins.Cigb0uSy.js → plugins.DPQHVT0p.js} +1 -1
  38. package/dist/chunks/{resolver.NpfwMKt9.js → resolver.CtCcxIy1.js} +1 -1
  39. package/dist/chunks/{rpc.CJVl3hZH.js → rpc.DpkUyY1N.js} +3 -2
  40. package/dist/chunks/{rpc.d.DA9Utv4e.d.ts → rpc.d.Cft1biqy.d.ts} +2 -1
  41. package/dist/chunks/{run.C5UmxDPh.js → run.Cm2sd7-x.js} +122 -97
  42. package/dist/chunks/{setup-common.Ct8rQvjH.js → setup-common.BABL3z3m.js} +3 -3
  43. package/dist/chunks/{source-map.BH0bbrs9.js → source-map.DdKI5IHB.js} +15 -10
  44. package/dist/chunks/{source-map.d.YqWNcp4e.d.ts → source-map.d.kzFtk_dj.d.ts} +1 -1
  45. package/dist/chunks/{spy.KLHgXex_.js → spy.DDMXghXv.js} +63 -32
  46. package/dist/chunks/{task-utils.d.BZm4GSQD.d.ts → task-utils.d.PFh2BV6Q.d.ts} +1 -1
  47. package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
  48. package/dist/chunks/{utils.CJ0JImL8.js → utils.DSfl_w8V.js} +44 -42
  49. package/dist/chunks/{vm.KI2AYADz.js → vm.Uo_C9Uld.js} +16 -13
  50. package/dist/chunks/{worker.d.MLmnzOJE.d.ts → worker.d.BH-r1bPu.d.ts} +8 -3
  51. package/dist/cli.js +4 -4
  52. package/dist/config.cjs +1 -1
  53. package/dist/config.d.ts +9 -10
  54. package/dist/config.js +2 -2
  55. package/dist/index.d.ts +10 -10
  56. package/dist/index.js +10 -10
  57. package/dist/module-evaluator.d.ts +3 -2
  58. package/dist/module-evaluator.js +8 -5
  59. package/dist/node.d.ts +9 -10
  60. package/dist/node.js +27 -26
  61. package/dist/runtime.d.ts +6 -6
  62. package/dist/runtime.js +4 -4
  63. package/dist/spy.js +1 -1
  64. package/dist/task-utils.js +7 -4
  65. package/dist/worker.d.ts +4 -4
  66. package/dist/worker.js +21 -20
  67. package/dist/workers/forks.js +19 -18
  68. package/dist/workers/runVmTests.js +23 -14
  69. package/dist/workers/threads.js +19 -18
  70. package/dist/workers/vmForks.js +13 -13
  71. package/dist/workers/vmThreads.js +13 -13
  72. package/globals.d.ts +19 -19
  73. package/index.cjs +3 -3
  74. package/optional-runtime-types.d.ts +1 -1
  75. package/optional-types.d.ts +1 -1
  76. package/package.json +35 -29
  77. package/suppress-warnings.cjs +1 -1
  78. package/dist/chunks/cli-api.DL4Bd7Vh.js +0 -528
  79. package/dist/chunks/tinyrainbow.Ht9iggcq.js +0 -95
@@ -6,13 +6,38 @@ const MOCK_RESTORE = /* @__PURE__ */ new Set();
6
6
  // but it makes the state slower to access and return different values
7
7
  // if you stored it before calling `mockClear` where it will be recreated
8
8
  const DIRTY_MOCK_STATES = /* @__PURE__ */ new Set();
9
- const addDirtyMock = DIRTY_MOCK_STATES.add.bind(DIRTY_MOCK_STATES);
10
- const REGISTERED_MOCKS = /* @__PURE__ */ new Set();
9
+ // Mocks whose implementation, once-queue or name changed since their last
10
+ // `mockReset()`, so `resetAllMocks()` only visits mocks that are not already reset
11
+ const DIRTY_MOCK_CONFIGS = /* @__PURE__ */ new Set();
12
+ // a test may spy on `Set.prototype.add`, and the spy itself marks mocks dirty
13
+ const addToSet = Set.prototype.add;
14
+ const MOCK_REFS = /* @__PURE__ */ new WeakMap();
11
15
  const MOCK_FINALIZER = new FinalizationRegistry((ref) => {
12
- REGISTERED_MOCKS.delete(ref);
16
+ DIRTY_MOCK_STATES.delete(ref);
17
+ DIRTY_MOCK_CONFIGS.delete(ref);
13
18
  });
14
19
  const MOCK_CONFIGS = /* @__PURE__ */ new WeakMap();
15
20
  const MOCKS_BY_STATE = /* @__PURE__ */ new WeakMap();
21
+ function markDirty(set, mock) {
22
+ let ref = MOCK_REFS.get(mock);
23
+ if (!ref) {
24
+ ref = new WeakRef(mock);
25
+ MOCK_REFS.set(mock, ref);
26
+ MOCK_FINALIZER.register(mock, ref);
27
+ }
28
+ addToSet.call(set, ref);
29
+ }
30
+ function unmarkDirty(set, mock) {
31
+ const ref = MOCK_REFS.get(mock);
32
+ if (ref) set.delete(ref);
33
+ }
34
+ function forEachDirty(set, fn) {
35
+ for (const ref of set) {
36
+ const mock = ref.deref();
37
+ if (mock) fn(mock);
38
+ else set.delete(ref);
39
+ }
40
+ }
16
41
  function createMockInstance(options = {}) {
17
42
  const { originalImplementation, restore, mockImplementation, resetToMockImplementation, resetToMockName } = options;
18
43
  if (restore) MOCK_RESTORE.add(restore);
@@ -36,9 +61,6 @@ function createMockInstance(options = {}) {
36
61
  if (resetToMockName) config.mockName = mock.name || "vi.fn()";
37
62
  MOCK_CONFIGS.set(mock, config);
38
63
  MOCKS_BY_STATE.set(state, mock);
39
- const ref = new WeakRef(mock);
40
- REGISTERED_MOCKS.add(ref);
41
- MOCK_FINALIZER.register(mock, ref);
42
64
  mock._isMockFunction = true;
43
65
  mock.getMockImplementation = () => {
44
66
  // Jest only returns `config.mockImplementation` here,
@@ -59,21 +81,25 @@ function createMockInstance(options = {}) {
59
81
  value: state
60
82
  });
61
83
  mock.mockImplementation = function mockImplementation(implementation) {
84
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
62
85
  config.mockImplementation = implementation;
63
86
  updateMockPrototype();
64
87
  return mock;
65
88
  };
66
89
  mock.mockImplementationOnce = function mockImplementationOnce(implementation) {
90
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
67
91
  config.onceMockImplementations.push(implementation);
68
92
  updateMockPrototype();
69
93
  return mock;
70
94
  };
71
95
  mock.withImplementation = function withImplementation(implementation, callback) {
96
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
72
97
  const previousImplementation = config.mockImplementation;
73
98
  const previousOnceImplementations = config.onceMockImplementations;
74
99
  const reset = () => {
75
100
  config.mockImplementation = previousImplementation;
76
101
  config.onceMockImplementations = previousOnceImplementations;
102
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
77
103
  updateMockPrototype();
78
104
  };
79
105
  config.mockImplementation = implementation;
@@ -105,13 +131,13 @@ function createMockInstance(options = {}) {
105
131
  });
106
132
  };
107
133
  mock.mockThrow = function mockThrow(value) {
108
- // eslint-disable-next-line prefer-arrow-callback
134
+ // oxlint-disable-next-line prefer-arrow-callback
109
135
  return mock.mockImplementation(function() {
110
136
  throw value;
111
137
  });
112
138
  };
113
139
  mock.mockThrowOnce = function mockThrowOnce(value) {
114
- // eslint-disable-next-line prefer-arrow-callback
140
+ // oxlint-disable-next-line prefer-arrow-callback
115
141
  return mock.mockImplementationOnce(function() {
116
142
  throw value;
117
143
  });
@@ -147,7 +173,7 @@ function createMockInstance(options = {}) {
147
173
  state.invocationCallOrder = [];
148
174
  state.results = [];
149
175
  state.settledResults = [];
150
- DIRTY_MOCK_STATES.delete(mock);
176
+ unmarkDirty(DIRTY_MOCK_STATES, mock);
151
177
  return mock;
152
178
  };
153
179
  mock.mockReset = function mockReset() {
@@ -155,6 +181,7 @@ function createMockInstance(options = {}) {
155
181
  config.mockImplementation = resetToMockImplementation ? mockImplementation : void 0;
156
182
  config.mockName = resetToMockName ? mock.name || "vi.fn()" : "vi.fn()";
157
183
  config.onceMockImplementations = [];
184
+ unmarkDirty(DIRTY_MOCK_CONFIGS, mock);
158
185
  updateMockPrototype();
159
186
  return mock;
160
187
  };
@@ -163,7 +190,10 @@ function createMockInstance(options = {}) {
163
190
  return restore?.();
164
191
  };
165
192
  mock.mockName = function mockName(name) {
166
- if (typeof name === "string") config.mockName = name;
193
+ if (typeof name === "string") {
194
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
195
+ config.mockName = name;
196
+ }
167
197
  return mock;
168
198
  };
169
199
  mock.getMockName = function getMockName() {
@@ -268,9 +298,9 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
268
298
  const prototypeMock = prototypeState && MOCKS_BY_STATE.get(prototypeState);
269
299
  const namedObject = {
270
300
  // to keep the name of the function intact
271
- [name]: (function(...args) {
272
- addDirtyMock(namedObject[name]);
273
- if (prototypeMock) addDirtyMock(prototypeMock);
301
+ [name]: function(...args) {
302
+ markDirty(DIRTY_MOCK_STATES, namedObject[name]);
303
+ if (prototypeMock) markDirty(DIRTY_MOCK_STATES, prototypeMock);
274
304
  registerCalls(args, state, prototypeState);
275
305
  registerInvocationOrder(invocationCallCounter++, state, prototypeState);
276
306
  const result = {
@@ -295,9 +325,11 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
295
325
  // the prototype chain is already prepared when the implementation
296
326
  // is registered, but a consumed `mockImplementationOnce` can change
297
327
  // which implementation this construction uses
298
- if (prototypeMembers.length === 0)
299
- // eslint-disable-next-line ts/no-use-before-define
300
- reparentMockPrototype(mock, implementation === noopImplementation ? void 0 : implementation);
328
+ if (prototypeMembers.length === 0) reparentMockPrototype(
329
+ // oxlint-disable-next-line typescript/no-use-before-define
330
+ mock,
331
+ implementation === noopImplementation ? void 0 : implementation
332
+ );
301
333
  returnValue = Reflect.construct(implementation, args, new.target);
302
334
  // jest calls this before the implementation, but we have to resolve this _after_
303
335
  // because we cannot do it before the `Reflect.construct` called the custom implementation.
@@ -306,7 +338,7 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
306
338
  for (const prop of prototypeMembers) {
307
339
  const prototypeMock = returnValue[prop];
308
340
  // the method was overridden because of inheritance, ignore it
309
- // eslint-disable-next-line ts/no-use-before-define
341
+ // oxlint-disable-next-line typescript/no-use-before-define
310
342
  if (prototypeMock !== mock.prototype[prop]) continue;
311
343
  const isMock = isMockFunction(prototypeMock);
312
344
  const prototypeState = isMock ? prototypeMock.mock : void 0;
@@ -353,7 +385,7 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
353
385
  }
354
386
  }
355
387
  return returnValue;
356
- }) };
388
+ } };
357
389
  const mock = namedObject[name];
358
390
  const copyPropertiesFrom = original || pseudoOriginal;
359
391
  if (copyPropertiesFrom) copyOriginalStaticProperties(mock, copyPropertiesFrom);
@@ -451,28 +483,27 @@ function restoreAllMocks() {
451
483
  MOCK_RESTORE.clear();
452
484
  }
453
485
  function clearAllMocks() {
454
- for (const mock of DIRTY_MOCK_STATES) mock.mockClear();
486
+ forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockClear());
455
487
  }
456
488
  function resetAllMocks() {
457
- for (const ref of REGISTERED_MOCKS) {
458
- const mock = ref.deref();
459
- if (mock) mock.mockReset();
460
- else REGISTERED_MOCKS.delete(ref);
461
- }
489
+ // `mockReset()` removes the mock from both sets, so a mock present in both
490
+ // is visited once.
491
+ forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockReset());
492
+ forEachDirty(DIRTY_MOCK_CONFIGS, (mock) => mock.mockReset());
462
493
  }
463
494
  function throwConstructorError(shorthand) {
464
495
  throw new TypeError(`Cannot use \`${shorthand}\` when called with \`new\`. Use \`mockImplementation\` with a \`class\` keyword instead. See https://vitest.dev/api/mock#class-support for more information.`);
465
496
  }
466
497
 
467
498
  var spyModule = /*#__PURE__*/Object.freeze({
468
- __proto__: null,
469
- clearAllMocks: clearAllMocks,
470
- createMockInstance: createMockInstance,
471
- fn: fn,
472
- isMockFunction: isMockFunction,
473
- resetAllMocks: resetAllMocks,
474
- restoreAllMocks: restoreAllMocks,
475
- spyOn: spyOn
499
+ __proto__: null,
500
+ clearAllMocks: clearAllMocks,
501
+ createMockInstance: createMockInstance,
502
+ fn: fn,
503
+ isMockFunction: isMockFunction,
504
+ resetAllMocks: resetAllMocks,
505
+ restoreAllMocks: restoreAllMocks,
506
+ spyOn: spyOn
476
507
  });
477
508
 
478
509
  export { spyOn as a, resetAllMocks as b, clearAllMocks as c, createMockInstance as d, fn as f, isMockFunction as i, restoreAllMocks as r, spyModule as s };
@@ -1,4 +1,4 @@
1
- import { bn as SnapshotState, m as Test, bo as PromisifyAssertion, bp as Tester, bq as Plugin, ad as BenchResult, a as File } from './config.d.CU_b-wJj.js';
1
+ import { bn as SnapshotState, m as Test, bo as PromisifyAssertion, bp as Tester, bq as Plugin, ad as BenchResult, a as File } from './config.d.QBNYCgFU.js';
2
2
 
3
3
  interface SnapshotMatcher<
4
4
  R extends void | Promise<void>,
@@ -0,0 +1,88 @@
1
+ // src/index.ts
2
+ var d = (e) => String(e);
3
+ d.open = d.close = "";
4
+ var i = () => d, t = "\x1B[39m", o = "\x1B[49m", F = (e, r, a, n, l) => {
5
+ let m = "", g = 0;
6
+ do
7
+ m += e.substring(g, n) + a, g = n + l, n = e.indexOf(r, g);
8
+ while (~n);
9
+ return m + e.substring(g);
10
+ }, u = (e, r, a = e, n = e.length) => {
11
+ let l = r.length, m = (g) => {
12
+ let s = g + "", x = s.indexOf(r, n);
13
+ return ~x ? e + F(s, r, a, x, l) + r : e + s + r;
14
+ };
15
+ return m.open = e, m.close = r, m;
16
+ }, B = (e, r) => u(e, r, e, 5), c = (e) => {
17
+ let r = e.charCodeAt(0) === 35 ? e.slice(1) : e, a = parseInt(r, 16) || 0;
18
+ return r.length < 6 ? `${(a >> 8 & 15) * 17};${(a >> 4 & 15) * 17};${(a & 15) * 17}` : `${a >> 16 & 255};${a >> 8 & 255};${a & 255}`;
19
+ };
20
+ function y(e) {
21
+ let r = e ? u : i;
22
+ return {
23
+ isColorSupported: e,
24
+ reset: r("\x1B[0m", "\x1B[0m"),
25
+ bold: r("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
26
+ dim: r("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
27
+ italic: r("\x1B[3m", "\x1B[23m"),
28
+ underline: r("\x1B[4m", "\x1B[24m"),
29
+ inverse: r("\x1B[7m", "\x1B[27m"),
30
+ hidden: r("\x1B[8m", "\x1B[28m"),
31
+ strikethrough: r("\x1B[9m", "\x1B[29m"),
32
+ black: r("\x1B[30m", t),
33
+ red: r("\x1B[31m", t),
34
+ green: r("\x1B[32m", t),
35
+ yellow: r("\x1B[33m", t),
36
+ blue: r("\x1B[34m", t),
37
+ magenta: r("\x1B[35m", t),
38
+ cyan: r("\x1B[36m", t),
39
+ white: r("\x1B[37m", t),
40
+ gray: r("\x1B[90m", t),
41
+ bgBlack: r("\x1B[40m", o),
42
+ bgRed: r("\x1B[41m", o),
43
+ bgGreen: r("\x1B[42m", o),
44
+ bgYellow: r("\x1B[43m", o),
45
+ bgBlue: r("\x1B[44m", o),
46
+ bgMagenta: r("\x1B[45m", o),
47
+ bgCyan: r("\x1B[46m", o),
48
+ bgWhite: r("\x1B[47m", o),
49
+ blackBright: r("\x1B[90m", t),
50
+ redBright: r("\x1B[91m", t),
51
+ greenBright: r("\x1B[92m", t),
52
+ yellowBright: r("\x1B[93m", t),
53
+ blueBright: r("\x1B[94m", t),
54
+ magentaBright: r("\x1B[95m", t),
55
+ cyanBright: r("\x1B[96m", t),
56
+ whiteBright: r("\x1B[97m", t),
57
+ bgBlackBright: r("\x1B[100m", o),
58
+ bgRedBright: r("\x1B[101m", o),
59
+ bgGreenBright: r("\x1B[102m", o),
60
+ bgYellowBright: r("\x1B[103m", o),
61
+ bgBlueBright: r("\x1B[104m", o),
62
+ bgMagentaBright: r("\x1B[105m", o),
63
+ bgCyanBright: r("\x1B[106m", o),
64
+ bgWhiteBright: r("\x1B[107m", o),
65
+ rgb: e ? (n, l, m) => B(`\x1B[38;2;${n};${l};${m}m`, t) : i,
66
+ bgRgb: e ? (n, l, m) => B(`\x1B[48;2;${n};${l};${m}m`, o) : i,
67
+ hex: e ? (n) => B(`\x1B[38;2;${c(n)}m`, t) : i,
68
+ bgHex: e ? (n) => B(`\x1B[48;2;${c(n)}m`, o) : i
69
+ };
70
+ }
71
+ function f() {
72
+ return y(false);
73
+ }
74
+ function C() {
75
+ let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", n = (e == null ? void 0 : e.argv) || [];
76
+ return !("NO_COLOR" in r || n.includes("--no-color")) && ("FORCE_COLOR" in r || n.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
77
+ }
78
+ function h({ force: e } = {}) {
79
+ let r = e || C();
80
+ return y(r);
81
+ }
82
+ var b = h();
83
+ function w() {
84
+ Object.assign(b, f());
85
+ }
86
+ var $ = b;
87
+
88
+ export { $, w };
@@ -1,7 +1,7 @@
1
1
  import { stripVTControlCharacters } from 'node:util';
2
- import { t as truncateString$1 } from './display.pkpxlVcY.js';
3
- import { i as isAbsolute, a as relative, d as dirname, b as basename, s as slash } from './pathe.M-eThtNZ.DwEga6ro.js';
4
- import { y } from './tinyrainbow.Ht9iggcq.js';
2
+ import { t as truncateString$1 } from './display.BlTmubjj.js';
3
+ import { i as isAbsolute, a as relative, d as dirname, b as basename, s as slash } from './pathe.M-eThtNZ.Ba-7h1rE.js';
4
+ import { $ } from './tinyrainbow.Do8I1XRG.js';
5
5
 
6
6
  const F_RIGHT = "→";
7
7
  const F_DOWN = "↓";
@@ -15,20 +15,20 @@ const F_TODO = "□";
15
15
  const F_TREE_NODE_MIDDLE = "├──";
16
16
  const F_TREE_NODE_END = "└──";
17
17
 
18
- const pointer = y.yellow(F_POINTER);
19
- const skipped = y.dim(y.gray(F_DOWN));
20
- const todo = y.dim(y.gray(F_TODO));
21
- const benchmarkPass = y.green(F_DOT);
22
- const testPass = y.green(F_CHECK);
23
- const taskFail = y.red(F_CROSS);
24
- const suiteFail = y.red(F_POINTER);
25
- const pending = y.gray("·");
26
- const separator = y.dim(" > ");
18
+ const pointer = $.yellow(F_POINTER);
19
+ const skipped = $.dim($.gray(F_DOWN));
20
+ const todo = $.dim($.gray(F_TODO));
21
+ const benchmarkPass = $.green(F_DOT);
22
+ const testPass = $.green(F_CHECK);
23
+ const taskFail = $.red(F_CROSS);
24
+ const suiteFail = $.red(F_POINTER);
25
+ const pending = $.gray("·");
26
+ const separator = $.dim(" > ");
27
27
  const labelDefaultColors = [
28
- y.bgYellow,
29
- y.bgCyan,
30
- y.bgGreen,
31
- y.bgMagenta
28
+ $.bgYellow,
29
+ $.bgCyan,
30
+ $.bgGreen,
31
+ $.bgMagenta
32
32
  ];
33
33
  function getCols(delta = 0) {
34
34
  let length = process.stdout?.columns;
@@ -36,7 +36,7 @@ function getCols(delta = 0) {
36
36
  return Math.max(length + delta, 0);
37
37
  }
38
38
  function errorBanner(message) {
39
- return divider(y.bold(y.bgRed(` ${message} `)), null, null, y.red);
39
+ return divider($.bold($.bgRed(` ${message} `)), null, null, $.red);
40
40
  }
41
41
  function divider(text, left, right, color) {
42
42
  const cols = getCols();
@@ -59,28 +59,30 @@ function formatTestPath(root, path) {
59
59
  const dir = dirname(path);
60
60
  const ext = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)?.[0] || "";
61
61
  const base = basename(path, ext);
62
- return slash(y.dim(`${dir}/`) + y.bold(base)) + y.dim(ext);
62
+ return slash($.dim(`${dir}/`) + $.bold(base)) + $.dim(ext);
63
63
  }
64
64
  function renderSnapshotSummary(rootDir, snapshots) {
65
65
  const summary = [];
66
- if (snapshots.added) summary.push(y.bold(y.green(`${snapshots.added} written`)));
67
- if (snapshots.unmatched) summary.push(y.bold(y.red(`${snapshots.unmatched} failed`)));
68
- if (snapshots.updated) summary.push(y.bold(y.green(`${snapshots.updated} updated `)));
69
- if (snapshots.filesRemoved) if (snapshots.didUpdate) summary.push(y.bold(y.green(`${snapshots.filesRemoved} files removed `)));
70
- else summary.push(y.bold(y.yellow(`${snapshots.filesRemoved} files obsolete `)));
66
+ if (snapshots.added) summary.push($.bold($.green(`${snapshots.added} written`)));
67
+ if (snapshots.unmatched) summary.push($.bold($.red(`${snapshots.unmatched} failed`)));
68
+ if (snapshots.updated) summary.push($.bold($.green(`${snapshots.updated} updated `)));
69
+ if (snapshots.filesRemoved) {
70
+ if (snapshots.didUpdate) summary.push($.bold($.green(`${snapshots.filesRemoved} files removed `)));
71
+ else summary.push($.bold($.yellow(`${snapshots.filesRemoved} files obsolete `)));
72
+ }
71
73
  if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
72
74
  const [head, ...tail] = snapshots.filesRemovedList;
73
- summary.push(`${y.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
75
+ summary.push(`${$.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
74
76
  tail.forEach((key) => {
75
- summary.push(` ${y.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
77
+ summary.push(` ${$.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
76
78
  });
77
79
  }
78
80
  if (snapshots.unchecked) {
79
- if (snapshots.didUpdate) summary.push(y.bold(y.green(`${snapshots.unchecked} removed`)));
80
- else summary.push(y.bold(y.yellow(`${snapshots.unchecked} obsolete`)));
81
+ if (snapshots.didUpdate) summary.push($.bold($.green(`${snapshots.unchecked} removed`)));
82
+ else summary.push($.bold($.yellow(`${snapshots.unchecked} obsolete`)));
81
83
  snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
82
- summary.push(`${y.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
83
- uncheckedFile.keys.forEach((key) => summary.push(` ${y.gray(F_DOT)} ${key}`));
84
+ summary.push(`${$.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
85
+ uncheckedFile.keys.forEach((key) => summary.push(` ${$.gray(F_DOT)} ${key}`));
84
86
  });
85
87
  }
86
88
  return summary;
@@ -89,7 +91,7 @@ function countTestErrors(tasks) {
89
91
  return tasks.reduce((c, i) => c + (i.result?.errors?.length || 0), 0);
90
92
  }
91
93
  function getStateString(tasks, name = "tests", showTotal = true) {
92
- if (tasks.length === 0) return y.dim(`no ${name}`);
94
+ if (tasks.length === 0) return $.dim(`no ${name}`);
93
95
  const passed = tasks.reduce((acc, i) => {
94
96
  // Exclude expected failures from passed count
95
97
  if (i.result?.state === "pass" && i.type === "test" && i.fails) return acc;
@@ -104,12 +106,12 @@ function getStateString(tasks, name = "tests", showTotal = true) {
104
106
  return acc;
105
107
  }, 0);
106
108
  return [
107
- failed ? y.bold(y.red(`${failed} failed`)) : null,
108
- passed ? y.bold(y.green(`${passed} passed`)) : null,
109
- expectedFail ? y.cyan(`${expectedFail} expected fail`) : null,
110
- skipped ? y.yellow(`${skipped} skipped`) : null,
111
- todo ? y.gray(`${todo} todo`) : null
112
- ].filter(Boolean).join(y.dim(" | ")) + (showTotal ? y.gray(` (${tasks.length})`) : "");
109
+ failed ? $.bold($.red(`${failed} failed`)) : null,
110
+ passed ? $.bold($.green(`${passed} passed`)) : null,
111
+ expectedFail ? $.cyan(`${expectedFail} expected fail`) : null,
112
+ skipped ? $.yellow(`${skipped} skipped`) : null,
113
+ todo ? $.gray(`${todo} todo`) : null
114
+ ].filter(Boolean).join($.dim(" | ")) + (showTotal ? $.gray(` (${tasks.length})`) : "");
113
115
  }
114
116
  function getStateSymbol(task) {
115
117
  if (task.mode === "todo") return todo;
@@ -131,20 +133,20 @@ function formatTime(time) {
131
133
  }
132
134
  function formatProjectName(project, suffix = " ") {
133
135
  if (!project?.name) return "";
134
- if (!y.isColorSupported) return `|${project.name}|${suffix}`;
135
- let background = project.color && y[`bg${capitalize(project.color)}`];
136
+ if (!$.isColorSupported) return `|${project.name}|${suffix}`;
137
+ let background = project.color && $[`bg${capitalize(project.color)}`];
136
138
  if (!background) {
137
139
  const index = project.name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
138
140
  background = labelDefaultColors[index % labelDefaultColors.length];
139
141
  }
140
- return y.black(background(` ${project.name} `)) + suffix;
142
+ return $.black(background(` ${project.name} `)) + suffix;
141
143
  }
142
144
  function withLabel(color, label, message) {
143
145
  const bgColor = `bg${color.charAt(0).toUpperCase()}${color.slice(1)}`;
144
- return `${y.bold(y.black(y[bgColor](` ${label} `)))} ${message ? y[color](message) : ""}`;
146
+ return `${$.bold($.black($[bgColor](` ${label} `)))} ${message ? $[color](message) : ""}`;
145
147
  }
146
148
  function padSummaryTitle(str) {
147
- return y.dim(`${str.padStart(11)} `);
149
+ return $.dim(`${str.padStart(11)} `);
148
150
  }
149
151
  function truncateString(text, maxLength) {
150
152
  return truncateString$1(stripVTControlCharacters(text), maxLength);
@@ -179,4 +181,4 @@ var utils = /*#__PURE__*/Object.freeze({
179
181
  withLabel: withLabel
180
182
  });
181
183
 
182
- export { F_POINTER as F, formatTimeString as a, taskFail as b, F_CHECK as c, divider as d, errorBanner as e, formatProjectName as f, F_DOWN_RIGHT as g, getStateSymbol as h, getStateString as i, formatTime as j, countTestErrors as k, F_TREE_NODE_END as l, F_TREE_NODE_MIDDLE as m, noun as n, F_RIGHT as o, padSummaryTitle as p, renderSnapshotSummary as r, separator as s, truncateString as t, utils as u, withLabel as w };
184
+ export { F_CHECK as F, F_POINTER as a, F_DOWN_RIGHT as b, formatProjectName as c, getStateString as d, formatTime as e, formatTimeString as f, getStateSymbol as g, countTestErrors as h, errorBanner as i, divider as j, F_TREE_NODE_END as k, F_TREE_NODE_MIDDLE as l, F_RIGHT as m, noun as n, truncateString as o, padSummaryTitle as p, renderSnapshotSummary as r, separator as s, taskFail as t, utils as u, withLabel as w };
@@ -1,18 +1,18 @@
1
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
2
2
  import v8 from 'node:v8';
3
3
  import vm, { isContext, runInContext } from 'node:vm';
4
- import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.IsjtLXKe.js';
4
+ import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.DrHtV5zd.js';
5
5
  import { distDir } from '../path.js';
6
- import { createCustomConsole } from './console.B09ye7y0.js';
6
+ import { createCustomConsole } from './console.DtI4yxfN.js';
7
7
  import fs__default from 'node:fs';
8
8
  import { createRequire, Module, isBuiltin } from 'node:module';
9
- import { d as dirname, f as extname, b as basename, C as CSS_LANGS_RE, h as KNOWN_ASSET_RE, t as toArray, k as splitFileAndPostfix, n as normalize, l as isBareImport, r as resolve } from './pathe.M-eThtNZ.DwEga6ro.js';
10
- import { l as lookupPackageScopeType } from './resolver.NpfwMKt9.js';
9
+ import { d as dirname, f as extname, b as basename, C as CSS_LANGS_RE, h as KNOWN_ASSET_RE, t as toArray, k as splitFileAndPostfix, n as normalize, l as isBareImport, r as resolve } from './pathe.M-eThtNZ.Ba-7h1rE.js';
10
+ import { l as lookupPackageScopeType } from './resolver.CtCcxIy1.js';
11
11
  import { initSync, parse } from 'es-module-lexer';
12
12
  import { dirname as dirname$1 } from 'node:path';
13
- import { V as VITEST_VM_CONTEXT_SYMBOL, s as startVitestModuleRunner, c as createNodeImportMeta } from './index.hTNFpC24.js';
13
+ import { V as VITEST_VM_CONTEXT_SYMBOL, s as startVitestModuleRunner, c as createNodeImportMeta } from './index.CPNMO3h-.js';
14
14
  import { getDefaultRequestStubs } from '../module-evaluator.js';
15
- import { b as setupEnv } from './setup-common.Ct8rQvjH.js';
15
+ import { b as setupEnv } from './setup-common.BABL3z3m.js';
16
16
  import { p as provideWorkerState } from './utils.DYj33du9.js';
17
17
 
18
18
  /**
@@ -219,7 +219,7 @@ class CommonjsExecutor {
219
219
  this.shouldRequireAsEsm = options.shouldRequireAsEsm;
220
220
  this.requireEsm = options.requireEsm;
221
221
  const primitives = vm.runInContext("({ Object, Array, Error })", this.context);
222
- // eslint-disable-next-line ts/no-this-alias
222
+ // oxlint-disable-next-line typescript/no-this-alias
223
223
  const executor = this;
224
224
  this.Module = class Module$1 {
225
225
  exports;
@@ -289,7 +289,7 @@ class CommonjsExecutor {
289
289
  const __dirname = dirname(filename);
290
290
  executor.requireCache.set(filename, this);
291
291
  try {
292
- fn(this.exports, this.require, this, filename, __dirname);
292
+ fn.call(this.exports, this.exports, this.require, this, filename, __dirname);
293
293
  return this.exports;
294
294
  } finally {
295
295
  this.loaded = true;
@@ -434,7 +434,7 @@ class CommonjsExecutor {
434
434
  let currentExtension;
435
435
  let index;
436
436
  let startIndex = 0;
437
- // eslint-disable-next-line no-cond-assign
437
+ // oxlint-disable-next-line no-cond-assign
438
438
  while ((index = name.indexOf(".", startIndex)) !== -1) {
439
439
  startIndex = index + 1;
440
440
  if (index === 0) continue;
@@ -1166,9 +1166,11 @@ class ExternalModulesExecutor {
1166
1166
  }
1167
1167
  }
1168
1168
  get isNetworkSupported() {
1169
- if (this.#networkSupported == null) if (process.execArgv.includes("--experimental-network-imports")) this.#networkSupported = true;
1170
- else if (process.env.NODE_OPTIONS?.includes("--experimental-network-imports")) this.#networkSupported = true;
1171
- else this.#networkSupported = false;
1169
+ if (this.#networkSupported == null) {
1170
+ if (process.execArgv.includes("--experimental-network-imports")) this.#networkSupported = true;
1171
+ else if (process.env.NODE_OPTIONS?.includes("--experimental-network-imports")) this.#networkSupported = true;
1172
+ else this.#networkSupported = false;
1173
+ }
1172
1174
  return this.#networkSupported;
1173
1175
  }
1174
1176
  }
@@ -1209,8 +1211,9 @@ const moduleInfoCache = /* @__PURE__ */ new Map();
1209
1211
  async function runVmTests(method, state, traces) {
1210
1212
  const { ctx, rpc } = state;
1211
1213
  const beforeEnvironmentTime = performance.now();
1212
- const { environment } = await loadEnvironment(ctx.environment.name, ctx.config.root, rpc, traces, true);
1214
+ const { environment, loader } = await loadEnvironment(ctx.environment.name, ctx.config.root, rpc, traces, true);
1213
1215
  state.environment = environment;
1216
+ loader?.evaluatedModules.idToModuleMap.forEach((_, id) => state.dependencies?.add(id));
1214
1217
  // let the server transform this file's import graph while this worker is
1215
1218
  // busy setting up the environment (jsdom takes ~0.5s per worker) —
1216
1219
  // the server is otherwise idle during that window on a cold start.
@@ -1,7 +1,7 @@
1
1
  import { EvaluatedModules } from 'vite/module-runner';
2
- import { F as FileSpecification, b as SerializedConfig, X as Task, Y as CancelReason } from './config.d.CU_b-wJj.js';
3
- import { a as RuntimeRPC, R as RunnerRPC, G as GetterTracker } from './rpc.d.DA9Utv4e.js';
4
- import { E as Environment } from './environment.d.C6xYahWA.js';
2
+ import { F as FileSpecification, b as SerializedConfig, X as Task, Y as CancelReason } from './config.d.QBNYCgFU.js';
3
+ import { a as RuntimeRPC, R as RunnerRPC, G as GetterTracker } from './rpc.d.Cft1biqy.js';
4
+ import { E as Environment } from './environment.d.BY56MoGs.js';
5
5
 
6
6
  //#region src/messages.d.ts
7
7
  declare const TYPE_REQUEST: "q";
@@ -246,6 +246,11 @@ interface WorkerGlobalState {
246
246
  evaluatedModules: EvaluatedModules;
247
247
  resolvingModules: Set<string>;
248
248
  moduleExecutionInfo: Map<string, any>;
249
+ /**
250
+ * Module ids and file paths loaded by the current test file. Only set when
251
+ * `experimental.recordDependencies` is enabled.
252
+ */
253
+ dependencies?: Set<string>;
249
254
  getterTracker?: GetterTracker;
250
255
  onCancel: (listener: (reason: CancelReason) => unknown) => () => void;
251
256
  onCleanup: (listener: () => unknown) => void;
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
- import { c as createCLI } from './chunks/cac.BLbEtnDd.js';
2
- import './chunks/pathe.M-eThtNZ.DwEga6ro.js';
1
+ import { c as createCLI } from './chunks/cac.DTXWs6Ni.js';
2
+ import './chunks/pathe.M-eThtNZ.Ba-7h1rE.js';
3
3
  import 'events';
4
- import './chunks/tinyrainbow.Ht9iggcq.js';
5
- import './chunks/env.DzFJjrmK.js';
4
+ import './chunks/tinyrainbow.Do8I1XRG.js';
5
+ import './chunks/env.BKKtU2WC.js';
6
6
  import 'std-env';
7
7
  import './chunks/constants.-juJ8b_4.js';
8
8
  import 'node:assert';
package/dist/config.cjs CHANGED
@@ -31,7 +31,7 @@ const coverageConfigDefaults = {
31
31
  ],
32
32
  allowExternal: false,
33
33
  excludeAfterRemap: false,
34
- processingConcurrency: Math.min(20, os.availableParallelism?.() ?? os.cpus().length),
34
+ processingConcurrency: Math.min(20, os.availableParallelism()),
35
35
  ignoreClassMethods: [],
36
36
  skipFull: false,
37
37
  watermarks: {
package/dist/config.d.ts CHANGED
@@ -1,25 +1,24 @@
1
1
  import { HookHandler, UserConfig, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { F as FieldsWithDefaultValues, U as UserWorkspaceConfig, a as UserProjectConfigFn, b as UserProjectConfigExport } from './chunks/plugin.d.My_z-jmU.js';
3
+ import { F as FieldsWithDefaultValues, U as UserWorkspaceConfig, a as UserProjectConfigFn, b as UserProjectConfigExport } from './chunks/plugin.d.C8mmycim.js';
4
4
  import { InlineConfig, ResolvedConfig, VitestPluginContext, CoverageOptions } from './node.js';
5
- export { T as TestProjectConfiguration, c as TestProjectInlineConfiguration, d as TestUserConfig, W as WatcherTriggerPattern } from './chunks/plugin.d.My_z-jmU.js';
6
- import { C as Config } from './chunks/config.d.CU_b-wJj.js';
7
- export { e as TestTagDefinition } from './chunks/config.d.CU_b-wJj.js';
5
+ export { T as TestProjectConfiguration, c as TestProjectInlineConfiguration, d as TestUserConfig, W as WatcherTriggerPattern } from './chunks/plugin.d.C8mmycim.js';
6
+ import { C as Config } from './chunks/config.d.QBNYCgFU.js';
7
+ export { e as TestTagDefinition } from './chunks/config.d.QBNYCgFU.js';
8
8
  import 'node:stream';
9
- import './chunks/browser.d.g5Thl309.js';
10
- import './chunks/rpc.d.DA9Utv4e.js';
9
+ import './chunks/browser.d.FGQ9_rK6.js';
10
+ import './chunks/rpc.d.Cft1biqy.js';
11
11
  import 'vite/module-runner';
12
- import './chunks/worker.d.MLmnzOJE.js';
13
- import './chunks/environment.d.C6xYahWA.js';
12
+ import './chunks/worker.d.BH-r1bPu.js';
13
+ import './chunks/environment.d.BY56MoGs.js';
14
14
  import 'chai';
15
15
  import 'vitest/optional-types.js';
16
16
  import '@vitest/mocker';
17
- import './chunks/source-map.d.YqWNcp4e.js';
17
+ import './chunks/source-map.d.kzFtk_dj.js';
18
18
  import 'vitest/browser';
19
19
  import 'node:path';
20
20
  import 'node:console';
21
21
  import 'node:fs/promises';
22
- import 'node:fs';
23
22
  import 'vitest/optional-runtime-types.js';
24
23
  import 'tinybench';
25
24
 
package/dist/config.js CHANGED
@@ -1,8 +1,8 @@
1
- export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.D2ip7f-X.js';
1
+ export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.B1FCaFfh.js';
2
2
  export { mergeConfig } from 'vite';
3
3
  export { d as defaultBrowserPort } from './chunks/constants.-juJ8b_4.js';
4
4
  import 'node:os';
5
- import './chunks/env.DzFJjrmK.js';
5
+ import './chunks/env.BKKtU2WC.js';
6
6
  import 'std-env';
7
7
 
8
8
  function defineConfig(config) {