@voidzero-dev/vite-plus-test 0.1.8 → 0.1.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 (205) hide show
  1. package/LICENSE.md +181 -1
  2. package/dist/@vitest/browser/client/.vite/manifest.json +6 -6
  3. package/dist/@vitest/browser/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
  4. package/dist/@vitest/browser/client/__vitest__/assets/index-Di71CKDo.js +63 -0
  5. package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
  6. package/dist/@vitest/browser/client/__vitest__/favicon.svg +49 -4
  7. package/dist/@vitest/browser/client/__vitest__/index.html +2 -2
  8. package/dist/@vitest/browser/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
  9. package/dist/@vitest/browser/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +167 -58
  10. package/dist/@vitest/browser/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
  11. package/dist/@vitest/browser/client/favicon.svg +49 -4
  12. package/dist/@vitest/browser/client/orchestrator.html +2 -2
  13. package/dist/@vitest/browser/client/tester/tester.html +2 -2
  14. package/dist/@vitest/browser/client.js +20 -13
  15. package/dist/@vitest/browser/context.d.ts +160 -10
  16. package/dist/@vitest/browser/context.js +108 -22
  17. package/dist/@vitest/browser/expect-element.js +23 -28
  18. package/dist/@vitest/browser/index-5Pe7X7sp.js +7 -0
  19. package/dist/@vitest/browser/index.d.ts +20 -2
  20. package/dist/@vitest/browser/index.js +5706 -159
  21. package/dist/@vitest/browser/locators.d.ts +14 -3
  22. package/dist/@vitest/browser/locators.js +1 -1
  23. package/dist/@vitest/browser-playwright/index.d.ts +22 -5
  24. package/dist/@vitest/browser-playwright/index.js +169 -61
  25. package/dist/@vitest/browser-preview/index.d.ts +14 -1
  26. package/dist/@vitest/browser-preview/locators.js +31 -18
  27. package/dist/@vitest/browser-webdriverio/index.d.ts +17 -3
  28. package/dist/@vitest/browser-webdriverio/index.js +22 -2
  29. package/dist/@vitest/browser-webdriverio/locators.js +84 -7
  30. package/dist/@vitest/expect/index.d.ts +172 -54
  31. package/dist/@vitest/expect/index.js +124 -67
  32. package/dist/@vitest/mocker/auto-register.js +1 -0
  33. package/dist/@vitest/mocker/automock.d.ts +1 -0
  34. package/dist/@vitest/mocker/automock.js +5 -0
  35. package/dist/@vitest/mocker/browser.d.ts +4 -4
  36. package/dist/@vitest/mocker/browser.js +1 -0
  37. package/dist/@vitest/mocker/chunk-automock.js +182 -14
  38. package/dist/@vitest/mocker/chunk-helpers.js +44 -0
  39. package/dist/@vitest/mocker/chunk-hoistMocks.js +659 -0
  40. package/dist/@vitest/mocker/chunk-mocker.js +41 -30
  41. package/dist/@vitest/mocker/chunk-registry.js +21 -7
  42. package/dist/@vitest/mocker/chunk-utils.js +18 -7
  43. package/dist/@vitest/mocker/hoistMocks.d-w2ILr1dG.d.ts +739 -0
  44. package/dist/@vitest/mocker/{index.d-C-sLYZi-.d.ts → index.d-B41z0AuW.d.ts} +1 -1
  45. package/dist/@vitest/mocker/index.d.ts +2 -2
  46. package/dist/@vitest/mocker/index.js +18 -3
  47. package/dist/@vitest/mocker/{mocker.d-TnKRhz7N.d.ts → mocker.d-QEntlm6J.d.ts} +10 -5
  48. package/dist/@vitest/mocker/node.d.ts +5 -734
  49. package/dist/@vitest/mocker/node.js +29 -587
  50. package/dist/@vitest/mocker/redirect.js +4 -4
  51. package/dist/@vitest/mocker/register.d.ts +3 -3
  52. package/dist/@vitest/mocker/register.js +1 -0
  53. package/dist/@vitest/mocker/transforms.d.ts +6 -0
  54. package/dist/@vitest/mocker/transforms.js +8 -0
  55. package/dist/@vitest/mocker/{types.d-B8CCKmHt.d.ts → types.d-BjI5eAwu.d.ts} +23 -7
  56. package/dist/@vitest/pretty-format/index.d.ts +11 -1
  57. package/dist/@vitest/pretty-format/index.js +33 -4
  58. package/dist/@vitest/runner/chunk-tasks.js +305 -37
  59. package/dist/@vitest/runner/index.d.ts +5 -6
  60. package/dist/@vitest/runner/index.js +1146 -455
  61. package/dist/@vitest/runner/{tasks.d-C7UxawJ9.d.ts → tasks.d-D2GKpdwQ.d.ts} +726 -55
  62. package/dist/@vitest/runner/types.d.ts +2 -182
  63. package/dist/@vitest/runner/utils.d.ts +16 -8
  64. package/dist/@vitest/runner/utils.js +1 -1
  65. package/dist/@vitest/snapshot/{environment.d-DHdQ1Csl.d.ts → environment.d-DOJxxZV9.d.ts} +2 -7
  66. package/dist/@vitest/snapshot/environment.d.ts +2 -1
  67. package/dist/@vitest/snapshot/environment.js +1 -1
  68. package/dist/@vitest/snapshot/index.d.ts +4 -3
  69. package/dist/@vitest/snapshot/index.js +21 -550
  70. package/dist/@vitest/snapshot/manager.d.ts +3 -2
  71. package/dist/@vitest/snapshot/manager.js +1 -1
  72. package/dist/@vitest/snapshot/{rawSnapshot.d-lFsMJFUd.d.ts → rawSnapshot.d-U2kJUxDr.d.ts} +1 -1
  73. package/dist/@vitest/spy/index.d.ts +34 -4
  74. package/dist/@vitest/spy/index.js +69 -19
  75. package/dist/@vitest/utils/diff.js +11 -9
  76. package/dist/@vitest/utils/display.d.ts +2 -1
  77. package/dist/@vitest/utils/display.js +38 -5
  78. package/dist/@vitest/utils/error.d.ts +2 -1
  79. package/dist/@vitest/utils/error.js +1 -2
  80. package/dist/@vitest/utils/helpers.d.ts +4 -1
  81. package/dist/@vitest/utils/helpers.js +43 -1
  82. package/dist/@vitest/utils/resolver.js +1 -2
  83. package/dist/@vitest/utils/serialize.js +6 -6
  84. package/dist/@vitest/utils/source-map/node.d.ts +6 -0
  85. package/dist/@vitest/utils/source-map/node.js +23 -0
  86. package/dist/@vitest/utils/source-map.js +15 -5
  87. package/dist/browser.d.ts +3 -2
  88. package/dist/browser.js +2 -2
  89. package/dist/chunks/acorn.B2iPLyUM.js +5958 -0
  90. package/dist/chunks/{base.CJ0Y4ePK.js → base.DM0-RqVb.js} +54 -16
  91. package/dist/chunks/{benchmark.B3N2zMcH.js → benchmark.D0SlKNbZ.js} +1 -1
  92. package/dist/chunks/{browser.d.ChKACdzH.d.ts → browser.d.X3SXoOCV.d.ts} +4 -1
  93. package/dist/chunks/{cac.DVeoLl0M.js → cac.CWGDZnXT.js} +979 -20
  94. package/dist/chunks/{cli-api.B7PN_QUv.js → cli-api.DuT9iuvY.js} +8764 -7898
  95. package/dist/chunks/{config.d.Cy95HiCx.d.ts → config.d.EJLVE3es.d.ts} +30 -15
  96. package/dist/chunks/{console.Cf-YriPC.js → console.3WNpx0tS.js} +3 -2
  97. package/dist/chunks/{constants.D_Q9UYh-.js → constants.CPYnjOGj.js} +4 -2
  98. package/dist/chunks/coverage.Bri33R1t.js +1050 -0
  99. package/dist/chunks/{creator.DAmOKTvJ.js → creator.DgVhQm5q.js} +35 -4
  100. package/dist/chunks/{defaults.BOqNVLsY.js → defaults.CdU2lD-q.js} +4 -3
  101. package/dist/chunks/{global.d.B15mdLcR.d.ts → global.d.x-ILCfAE.d.ts} +1 -2
  102. package/dist/chunks/{globals.DOayXfHP.js → globals.BXNGLnTL.js} +11 -10
  103. package/dist/chunks/{coverage.AVPTjMgw.js → index.BCY_7LL2.js} +5 -959
  104. package/dist/chunks/{index.C5r1PdPD.js → index.CEzQDJGb.js} +1 -1
  105. package/dist/chunks/{index.D3XRDfWc.js → index.CMESou6r.js} +26 -1
  106. package/dist/chunks/{index.6Qv1eEA6.js → index.DGNSnENe.js} +95 -9
  107. package/dist/chunks/{index.M8mOzt4Y.js → index.DXMFO5MJ.js} +3279 -2914
  108. package/dist/chunks/{index.Z5E_ObnR.js → index.DlDSLQD3.js} +7 -3
  109. package/dist/chunks/{index.CyBMJtT7.js → index.EY6TCHpo.js} +10 -8
  110. package/dist/chunks/{index.D4KonVSU.js → index.og1WyBLx.js} +18 -3
  111. package/dist/chunks/{init-forks._y3TW739.js → init-forks.DeArv0jT.js} +1 -1
  112. package/dist/chunks/{init-threads.DBO2kn-p.js → init-threads.-2OUl4Nn.js} +1 -1
  113. package/dist/chunks/{init.B6MLFIaN.js → init.DICorXCo.js} +52 -13
  114. package/dist/chunks/native.DPzPHdi5.js +148 -0
  115. package/dist/chunks/nativeModuleMocker.DndvSdL6.js +206 -0
  116. package/dist/chunks/nativeModuleRunner.BIakptoF.js +36 -0
  117. package/dist/chunks/{node.Ce0vMQM7.js → node.COQbm6gK.js} +1 -1
  118. package/dist/chunks/{plugin.d.CtqpEehP.d.ts → plugin.d.BuW-flqo.d.ts} +1 -1
  119. package/dist/chunks/{reporters.d.CWXNI2jG.d.ts → reporters.d.DVUYHHhe.d.ts} +328 -79
  120. package/dist/chunks/rpc.MzXet3jl.js +144 -0
  121. package/dist/chunks/{rpc.d.RH3apGEf.d.ts → rpc.d.BFMWpdph.d.ts} +10 -2
  122. package/dist/chunks/{setup-common.Cm-kSBVi.js → setup-common.B41N_kPE.js} +3 -3
  123. package/dist/chunks/{startModuleRunner.DEj0jb3e.js → startVitestModuleRunner.C3ZR-4J3.js} +265 -405
  124. package/dist/chunks/{suite.d.BJWk38HB.d.ts → suite.d.udJtyAgw.d.ts} +1 -1
  125. package/dist/chunks/{vi.2VT5v0um.js → test.CTcmp4Su.js} +538 -181
  126. package/dist/chunks/{utils.DvEY5TfP.js → utils.BX5Fg8C4.js} +8 -1
  127. package/dist/chunks/{vm.D3epNOPZ.js → vm.Dh2rTtmP.js} +48 -8
  128. package/dist/chunks/{worker.d.Dyxm8DEL.d.ts → worker.d.B84sVRy0.d.ts} +2 -2
  129. package/dist/cli.js +6 -5
  130. package/dist/client/.vite/manifest.json +6 -6
  131. package/dist/client/__vitest__/assets/index-Da0hb3oU.css +1 -0
  132. package/dist/client/__vitest__/assets/index-Di71CKDo.js +63 -0
  133. package/dist/client/__vitest__/favicon.ico +0 -0
  134. package/dist/client/__vitest__/favicon.svg +49 -4
  135. package/dist/client/__vitest__/index.html +2 -2
  136. package/dist/client/__vitest_browser__/{orchestrator-S_3e_uzt.js → orchestrator-CXs6qrFe.js} +70 -28
  137. package/dist/client/__vitest_browser__/{tester-k74mgIRa.js → tester-K5NNxh1O.js} +167 -58
  138. package/dist/client/__vitest_browser__/{utils-uxqdqUz8.js → utils-C2ISqq1C.js} +2 -2
  139. package/dist/client/favicon.svg +49 -4
  140. package/dist/client/orchestrator.html +2 -2
  141. package/dist/client/tester/tester.html +2 -2
  142. package/dist/client.js +20 -13
  143. package/dist/config.cjs +3 -2
  144. package/dist/config.d.ts +13 -12
  145. package/dist/config.js +2 -2
  146. package/dist/context.js +108 -22
  147. package/dist/coverage.d.ts +12 -8
  148. package/dist/coverage.js +8 -5
  149. package/dist/environments.js +3 -1
  150. package/dist/expect-element.js +23 -23
  151. package/dist/index-5Pe7X7sp.js +7 -0
  152. package/dist/index.d.ts +66 -27
  153. package/dist/index.js +10 -9
  154. package/dist/locators.d.ts +14 -3
  155. package/dist/locators.js +1 -1
  156. package/dist/module-evaluator.d.ts +11 -1
  157. package/dist/module-evaluator.js +43 -26
  158. package/dist/node.d.ts +28 -14
  159. package/dist/node.js +42 -40
  160. package/dist/nodejs-worker-loader.js +41 -0
  161. package/dist/plugins/mocker-transforms.mjs +2 -0
  162. package/dist/plugins/utils-source-map-node.mjs +2 -0
  163. package/dist/reporters.d.ts +8 -8
  164. package/dist/reporters.js +7 -5
  165. package/dist/runners.d.ts +24 -5
  166. package/dist/runners.js +6 -6
  167. package/dist/runtime.d.ts +6 -0
  168. package/dist/runtime.js +35 -0
  169. package/dist/snapshot.js +4 -2
  170. package/dist/suite.d.ts +1 -1
  171. package/dist/suite.js +4 -2
  172. package/dist/vendor/blazediff_core.d.mts +1 -0
  173. package/dist/vendor/blazediff_core.mjs +117 -0
  174. package/dist/vendor/chai.mjs +4 -249
  175. package/dist/vendor/convert-source-map.d.mts +1 -0
  176. package/dist/vendor/convert-source-map.mjs +150 -0
  177. package/dist/vendor/expect-type.d.mts +14 -7
  178. package/dist/vendor/expect-type.mjs +5 -5
  179. package/dist/vendor/std-env.d.mts +131 -40
  180. package/dist/vendor/std-env.mjs +114 -117
  181. package/dist/worker.d.ts +6 -6
  182. package/dist/worker.js +27 -21
  183. package/dist/workers/forks.js +23 -17
  184. package/dist/workers/runVmTests.js +18 -16
  185. package/dist/workers/threads.js +23 -17
  186. package/dist/workers/vmForks.js +15 -12
  187. package/dist/workers/vmThreads.js +15 -12
  188. package/globals.d.ts +2 -0
  189. package/package.json +36 -27
  190. package/suppress-warnings.cjs +1 -0
  191. package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +0 -57
  192. package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
  193. package/dist/@vitest/browser/index-D6m36C6U.js +0 -11
  194. package/dist/@vitest/utils/chunk-_commonjsHelpers.js +0 -5
  195. package/dist/@vitest/utils/highlight.d.ts +0 -9
  196. package/dist/@vitest/utils/highlight.js +0 -538
  197. package/dist/chunks/date.Bq6ZW5rf.js +0 -73
  198. package/dist/chunks/rpc.BoxB0q7B.js +0 -76
  199. package/dist/chunks/test.B8ej_ZHS.js +0 -254
  200. package/dist/client/__vitest__/assets/index-BUCFJtth.js +0 -57
  201. package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +0 -1
  202. package/dist/index-D6m36C6U.js +0 -6
  203. package/dist/mocker.d.ts +0 -1
  204. package/dist/mocker.js +0 -1
  205. package/dist/module-runner.js +0 -17
@@ -1,6 +1,6 @@
1
1
  import { printDiffOrStringify, diff } from '../utils/diff.js';
2
2
  import { stringify } from '../utils/display.js';
3
- import { getType, isObject, noop, assertTypes } from '../utils/helpers.js';
3
+ import { getType, isObject, noop, assertTypes, ordinal } from '../utils/helpers.js';
4
4
  import c from '../../vendor/tinyrainbow.mjs';
5
5
  import { isMockFunction } from '../spy/index.js';
6
6
  import { processError } from '../utils/error.js';
@@ -8,6 +8,52 @@ import { use, util } from '../../vendor/chai.mjs';
8
8
  import * as chai from '../../vendor/chai.mjs';
9
9
  export { chai };
10
10
 
11
+ const ChaiStyleAssertions = (chai, utils) => {
12
+ function defProperty(name, delegateTo) {
13
+ utils.addProperty(chai.Assertion.prototype, name, function() {
14
+ const jestMethod = chai.Assertion.prototype[delegateTo];
15
+ if (!jestMethod) {
16
+ throw new Error(`Cannot delegate to ${String(delegateTo)}: method not found. Ensure JestChaiExpect plugin is loaded first.`);
17
+ }
18
+ return jestMethod.call(this);
19
+ });
20
+ }
21
+ function defPropertyWithArgs(name, delegateTo, ...args) {
22
+ utils.addProperty(chai.Assertion.prototype, name, function() {
23
+ const jestMethod = chai.Assertion.prototype[delegateTo];
24
+ if (!jestMethod) {
25
+ throw new Error(`Cannot delegate to ${String(delegateTo)}: method not found. Ensure JestChaiExpect plugin is loaded first.`);
26
+ }
27
+ return jestMethod.call(this, ...args);
28
+ });
29
+ }
30
+ function defMethod(name, delegateTo) {
31
+ utils.addChainableMethod(chai.Assertion.prototype, name, function(...args) {
32
+ const jestMethod = chai.Assertion.prototype[delegateTo];
33
+ if (!jestMethod) {
34
+ throw new Error(`Cannot delegate to ${String(delegateTo)}: method not found. Ensure JestChaiExpect plugin is loaded first.`);
35
+ }
36
+ return jestMethod.call(this, ...args);
37
+ }, () => {});
38
+ }
39
+ defProperty("called", "toHaveBeenCalled");
40
+ defProperty("calledOnce", "toHaveBeenCalledOnce");
41
+ defProperty("returned", "toHaveReturned");
42
+ defPropertyWithArgs("calledTwice", "toHaveBeenCalledTimes", 2);
43
+ defPropertyWithArgs("calledThrice", "toHaveBeenCalledTimes", 3);
44
+ defMethod("callCount", "toHaveBeenCalledTimes");
45
+ defMethod("calledWith", "toHaveBeenCalledWith");
46
+ defMethod("calledOnceWith", "toHaveBeenCalledExactlyOnceWith");
47
+ defMethod("lastCalledWith", "toHaveBeenLastCalledWith");
48
+ defMethod("nthCalledWith", "toHaveBeenNthCalledWith");
49
+ defMethod("returnedWith", "toHaveReturnedWith");
50
+ defMethod("returnedTimes", "toHaveReturnedTimes");
51
+ defMethod("lastReturnedWith", "toHaveLastReturnedWith");
52
+ defMethod("nthReturnedWith", "toHaveNthReturnedWith");
53
+ defMethod("calledBefore", "toHaveBeenCalledBefore");
54
+ defMethod("calledAfter", "toHaveBeenCalledAfter");
55
+ };
56
+
11
57
  const MATCHERS_OBJECT = Symbol.for("matchers-object");
12
58
  const JEST_MATCHERS_OBJECT = Symbol.for("$$jest-matchers-object");
13
59
  const GLOBAL_EXPECT = Symbol.for("expect-global");
@@ -198,6 +244,18 @@ function asymmetricMatch(a, b, customTesters) {
198
244
  return b.asymmetricMatch(a, customTesters);
199
245
  }
200
246
  }
247
+ // https://github.com/jestjs/jest/blob/905bcbced3d40cdf7aadc4cdf6fb731c4bb3dbe3/packages/expect-utils/src/utils.ts#L509
248
+ function isError(value) {
249
+ if (typeof Error.isError === "function") {
250
+ return Error.isError(value);
251
+ }
252
+ switch (Object.prototype.toString.call(value)) {
253
+ case "[object Error]":
254
+ case "[object Exception]":
255
+ case "[object DOMException]": return true;
256
+ default: return value instanceof Error;
257
+ }
258
+ }
201
259
  // Equality function lovingly adapted from isEqual in
202
260
  // [Underscore](http://underscorejs.org)
203
261
  function eq(a, b, aStack, bStack, customTesters, hasKey) {
@@ -286,7 +344,7 @@ function eq(a, b, aStack, bStack, customTesters, hasKey) {
286
344
  if (className === "[object Array]" && a.length !== b.length) {
287
345
  return false;
288
346
  }
289
- if (a instanceof Error && b instanceof Error) {
347
+ if (isError(a) && isError(b)) {
290
348
  try {
291
349
  return isErrorEqual(a, b, aStack, bStack, customTesters, hasKey);
292
350
  } finally {
@@ -320,17 +378,17 @@ function isErrorEqual(a, b, aStack, bStack, customTesters, hasKey) {
320
378
  // - [[Prototype]] of objects are compared using the === operator.
321
379
  // - Only enumerable "own" properties are considered.
322
380
  // - Error names, messages, causes, and errors are always compared, even if these are not enumerable properties. errors is also compared.
323
- let result = Object.getPrototypeOf(a) === Object.getPrototypeOf(b) && a.name === b.name && a.message === b.message;
381
+ let result = Object.prototype.toString.call(a) === Object.prototype.toString.call(b) && a.name === b.name && a.message === b.message;
324
382
  // check Error.cause asymmetrically
325
383
  if (typeof b.cause !== "undefined") {
326
- result && (result = eq(a.cause, b.cause, aStack, bStack, customTesters, hasKey));
384
+ result &&= eq(a.cause, b.cause, aStack, bStack, customTesters, hasKey);
327
385
  }
328
386
  // AggregateError.errors
329
387
  if (a instanceof AggregateError && b instanceof AggregateError) {
330
- result && (result = eq(a.errors, b.errors, aStack, bStack, customTesters, hasKey));
388
+ result &&= eq(a.errors, b.errors, aStack, bStack, customTesters, hasKey);
331
389
  }
332
390
  // spread to compare enumerable properties
333
- result && (result = eq({ ...a }, { ...b }, aStack, bStack, customTesters, hasKey));
391
+ result &&= eq({ ...a }, { ...b }, aStack, bStack, customTesters, hasKey);
334
392
  return result;
335
393
  }
336
394
  function keys(obj, hasKey) {
@@ -524,7 +582,7 @@ function hasPropertyInObject(object, key) {
524
582
  return Object.hasOwn(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
525
583
  }
526
584
  function isObjectWithKeys(a) {
527
- return isObject(a) && !(a instanceof Error) && !Array.isArray(a) && !(a instanceof Date);
585
+ return isObject(a) && !isError(a) && !Array.isArray(a) && !(a instanceof Date) && !(a instanceof Set) && !(a instanceof Map);
528
586
  }
529
587
  function subsetEquality(object, subset, customTesters = []) {
530
588
  const filteredCustomTesters = customTesters.filter((t) => t !== subsetEquality);
@@ -607,10 +665,7 @@ function pluralize(word, count) {
607
665
  return `${count} ${word}${count === 1 ? "" : "s"}`;
608
666
  }
609
667
  function getObjectKeys(object) {
610
- return [...Object.keys(object), ...Object.getOwnPropertySymbols(object).filter((s) => {
611
- var _Object$getOwnPropert;
612
- return (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(object, s)) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.enumerable;
613
- })];
668
+ return [...Object.keys(object), ...Object.getOwnPropertySymbols(object).filter((s) => Object.getOwnPropertyDescriptor(object, s)?.enumerable)];
614
669
  }
615
670
  function getObjectSubset(object, subset, customTesters) {
616
671
  let stripped = 0;
@@ -788,10 +843,7 @@ class ObjectContaining extends AsymmetricMatcher {
788
843
  return this.hasProperty(this.getPrototype(obj), property);
789
844
  }
790
845
  getProperties(obj) {
791
- return [...Object.keys(obj), ...Object.getOwnPropertySymbols(obj).filter((s) => {
792
- var _Object$getOwnPropert;
793
- return (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(obj, s)) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.enumerable;
794
- })];
846
+ return [...Object.keys(obj), ...Object.getOwnPropertySymbols(obj).filter((s) => Object.getOwnPropertyDescriptor(obj, s)?.enumerable)];
795
847
  }
796
848
  asymmetricMatch(other, customTesters) {
797
849
  if (typeof this.sample !== "object") {
@@ -800,13 +852,12 @@ class ObjectContaining extends AsymmetricMatcher {
800
852
  let result = true;
801
853
  const properties = this.getProperties(this.sample);
802
854
  for (const property of properties) {
803
- var _Object$getOwnPropert2, _Object$getOwnPropert3;
804
855
  if (!this.hasProperty(other, property)) {
805
856
  result = false;
806
857
  break;
807
858
  }
808
- const value = ((_Object$getOwnPropert2 = Object.getOwnPropertyDescriptor(this.sample, property)) === null || _Object$getOwnPropert2 === void 0 ? void 0 : _Object$getOwnPropert2.value) ?? this.sample[property];
809
- const otherValue = ((_Object$getOwnPropert3 = Object.getOwnPropertyDescriptor(other, property)) === null || _Object$getOwnPropert3 === void 0 ? void 0 : _Object$getOwnPropert3.value) ?? other[property];
859
+ const value = this.sample[property];
860
+ const otherValue = other[property];
810
861
  if (!equals(value, otherValue, customTesters)) {
811
862
  result = false;
812
863
  break;
@@ -987,9 +1038,8 @@ class SchemaMatching extends AsymmetricMatcher {
987
1038
  return "object";
988
1039
  }
989
1040
  toAsymmetricMatcher() {
990
- var _this$result;
991
1041
  const { utils } = this.getMatcherContext();
992
- const issues = ((_this$result = this.result) === null || _this$result === void 0 ? void 0 : _this$result.issues) || [];
1042
+ const issues = this.result?.issues || [];
993
1043
  if (issues.length > 0) {
994
1044
  return `${this.toString()} ${utils.stringify(this.result, undefined, { printBasicPrototype: false })}`;
995
1045
  }
@@ -1017,13 +1067,14 @@ const JestAsymmetricMatchers = (chai, utils) => {
1017
1067
  };
1018
1068
 
1019
1069
  function createAssertionMessage(util, assertion, hasArgs) {
1070
+ const soft = util.flag(assertion, "soft") ? ".soft" : "";
1020
1071
  const not = util.flag(assertion, "negate") ? "not." : "";
1021
1072
  const name = `${util.flag(assertion, "_name")}(${hasArgs ? "expected" : ""})`;
1022
1073
  const promiseName = util.flag(assertion, "promise");
1023
1074
  const promise = promiseName ? `.${promiseName}` : "";
1024
- return `expect(actual)${promise}.${not}${name}`;
1075
+ return `expect${soft}(actual)${promise}.${not}${name}`;
1025
1076
  }
1026
- function recordAsyncExpect(_test, promise, assertion, error) {
1077
+ function recordAsyncExpect(_test, promise, assertion, error, isSoft) {
1027
1078
  const test = _test;
1028
1079
  // record promise for test, that resolves before test ends
1029
1080
  if (test && promise instanceof Promise) {
@@ -1041,17 +1092,23 @@ function recordAsyncExpect(_test, promise, assertion, error) {
1041
1092
  if (!test.promises) {
1042
1093
  test.promises = [];
1043
1094
  }
1095
+ // setup `expect.soft` handler here instead of `wrapAssertion`
1096
+ // to avoid double error tracking while keeping non-await promise detection.
1097
+ if (isSoft) {
1098
+ promise = promise.then(noop, (err) => {
1099
+ handleTestError(test, err);
1100
+ });
1101
+ }
1044
1102
  test.promises.push(promise);
1045
1103
  let resolved = false;
1046
- test.onFinished ?? (test.onFinished = []);
1104
+ test.onFinished ??= [];
1047
1105
  test.onFinished.push(() => {
1048
1106
  if (!resolved) {
1049
- var _vitest_worker__;
1050
- const processor = ((_vitest_worker__ = globalThis.__vitest_worker__) === null || _vitest_worker__ === void 0 ? void 0 : _vitest_worker__.onFilterStackTrace) || ((s) => s || "");
1107
+ const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
1051
1108
  const stack = processor(error.stack);
1052
1109
  console.warn([
1053
1110
  `Promise returned by \`${assertion}\` was not awaited. `,
1054
- "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
1111
+ "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in the next Vitest major. ",
1055
1112
  "Please remember to await the assertion.\n",
1056
1113
  stack
1057
1114
  ].join(""));
@@ -1063,9 +1120,11 @@ function recordAsyncExpect(_test, promise, assertion, error) {
1063
1120
  return promise.then(onFulfilled, onRejected);
1064
1121
  },
1065
1122
  catch(onRejected) {
1123
+ resolved = true;
1066
1124
  return promise.catch(onRejected);
1067
1125
  },
1068
1126
  finally(onFinally) {
1127
+ resolved = true;
1069
1128
  return promise.finally(onFinally);
1070
1129
  },
1071
1130
  [Symbol.toStringTag]: "Promise"
@@ -1074,10 +1133,9 @@ function recordAsyncExpect(_test, promise, assertion, error) {
1074
1133
  return promise;
1075
1134
  }
1076
1135
  function handleTestError(test, err) {
1077
- var _test$result;
1078
- test.result || (test.result = { state: "fail" });
1136
+ test.result ||= { state: "fail" };
1079
1137
  test.result.state = "fail";
1080
- (_test$result = test.result).errors || (_test$result.errors = []);
1138
+ test.result.errors ||= [];
1081
1139
  test.result.errors.push(processError(err));
1082
1140
  }
1083
1141
  function wrapAssertion(utils, name, fn) {
@@ -1087,7 +1145,11 @@ function wrapAssertion(utils, name, fn) {
1087
1145
  utils.flag(this, "_name", name);
1088
1146
  }
1089
1147
  if (!utils.flag(this, "soft")) {
1090
- return fn.apply(this, args);
1148
+ // avoid WebKit's proper tail call to preserve stacktrace offset for inline snapshot
1149
+ // https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-in-webkit
1150
+ try {
1151
+ return fn.apply(this, args);
1152
+ } finally {}
1091
1153
  }
1092
1154
  const test = utils.flag(this, "vitest-test");
1093
1155
  if (!test) {
@@ -1437,15 +1499,15 @@ const JestChaiExpect = (chai, utils) => {
1437
1499
  throw new AssertionError(formatCalls(spy, msg, args));
1438
1500
  }
1439
1501
  });
1440
- def(["toHaveBeenNthCalledWith", "nthCalledWith"], function(times, ...args) {
1502
+ def("toHaveBeenNthCalledWith", function(times, ...args) {
1441
1503
  const spy = getSpy(this);
1442
1504
  const spyName = spy.getMockName();
1443
1505
  const nthCall = spy.mock.calls[times - 1];
1444
1506
  const callCount = spy.mock.calls.length;
1445
1507
  const isCalled = times <= callCount;
1446
- this.assert(nthCall && equalsArgumentArray(nthCall, args), `expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}${isCalled ? `` : `, but called only ${callCount} times`}`, `expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`, args, nthCall, isCalled);
1508
+ this.assert(nthCall && equalsArgumentArray(nthCall, args), `expected ${ordinal(times)} "${spyName}" call to have been called with #{exp}${isCalled ? `` : `, but called only ${callCount} times`}`, `expected ${ordinal(times)} "${spyName}" call to not have been called with #{exp}`, args, nthCall, isCalled);
1447
1509
  });
1448
- def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
1510
+ def("toHaveBeenLastCalledWith", function(...args) {
1449
1511
  const spy = getSpy(this);
1450
1512
  const spyName = spy.getMockName();
1451
1513
  const lastCall = spy.mock.calls.at(-1);
@@ -1516,7 +1578,7 @@ const JestChaiExpect = (chai, utils) => {
1516
1578
  const name = expected.name || expected.prototype.constructor.name;
1517
1579
  return this.assert(thrown && thrown instanceof expected, `expected error to be instance of ${name}`, `expected error not to be instance of ${name}`, expected, thrown);
1518
1580
  }
1519
- if (expected instanceof Error) {
1581
+ if (isError(expected)) {
1520
1582
  const equal = equals(thrown, expected, [...customTesters, iterableEquality]);
1521
1583
  return this.assert(equal, "expected a thrown error to be #{exp}", "expected a thrown error not to be #{exp}", expected, thrown);
1522
1584
  }
@@ -1524,7 +1586,8 @@ const JestChaiExpect = (chai, utils) => {
1524
1586
  const matcher = expected;
1525
1587
  return this.assert(thrown && matcher.asymmetricMatch(thrown), "expected error to match asymmetric matcher", "expected error not to match asymmetric matcher", matcher, thrown);
1526
1588
  }
1527
- throw new Error(`"toThrow" expects string, RegExp, function, Error instance or asymmetric matcher, got "${typeof expected}"`);
1589
+ const equal = equals(thrown, expected, [...customTesters, iterableEquality]);
1590
+ return this.assert(equal, "expected a thrown value to equal #{exp}", "expected a thrown value not to equal #{exp}", expected, thrown);
1528
1591
  });
1529
1592
  [{
1530
1593
  name: "toHaveResolved",
@@ -1592,7 +1655,7 @@ const JestChaiExpect = (chai, utils) => {
1592
1655
  },
1593
1656
  action: "resolve"
1594
1657
  }, {
1595
- name: ["toHaveLastReturnedWith", "lastReturnedWith"],
1658
+ name: "toHaveLastReturnedWith",
1596
1659
  condition: (spy, value) => {
1597
1660
  const result = spy.mock.results.at(-1);
1598
1661
  return Boolean(result && result.type === "return" && equals(result.value, value));
@@ -1604,7 +1667,7 @@ const JestChaiExpect = (chai, utils) => {
1604
1667
  const results = action === "return" ? spy.mock.results : spy.mock.settledResults;
1605
1668
  const result = results.at(-1);
1606
1669
  const spyName = spy.getMockName();
1607
- this.assert(condition(spy, value), `expected last "${spyName}" call to ${action} #{exp}`, `expected last "${spyName}" call to not ${action} #{exp}`, value, result === null || result === void 0 ? void 0 : result.value);
1670
+ this.assert(condition(spy, value), `expected last "${spyName}" call to ${action} #{exp}`, `expected last "${spyName}" call to not ${action} #{exp}`, value, result?.value);
1608
1671
  });
1609
1672
  });
1610
1673
  [{
@@ -1615,7 +1678,7 @@ const JestChaiExpect = (chai, utils) => {
1615
1678
  },
1616
1679
  action: "resolve"
1617
1680
  }, {
1618
- name: ["toHaveNthReturnedWith", "nthReturnedWith"],
1681
+ name: "toHaveNthReturnedWith",
1619
1682
  condition: (spy, index, value) => {
1620
1683
  const result = spy.mock.results[index - 1];
1621
1684
  return result && result.type === "return" && equals(result.value, value);
@@ -1627,8 +1690,8 @@ const JestChaiExpect = (chai, utils) => {
1627
1690
  const spyName = spy.getMockName();
1628
1691
  const results = action === "return" ? spy.mock.results : spy.mock.settledResults;
1629
1692
  const result = results[nthCall - 1];
1630
- const ordinalCall = `${ordinalOf(nthCall)} call`;
1631
- this.assert(condition(spy, nthCall, value), `expected ${ordinalCall} "${spyName}" call to ${action} #{exp}`, `expected ${ordinalCall} "${spyName}" call to not ${action} #{exp}`, value, result === null || result === void 0 ? void 0 : result.value);
1693
+ const ordinalCall = `${ordinal(nthCall)} call`;
1694
+ this.assert(condition(spy, nthCall, value), `expected ${ordinalCall} "${spyName}" call to ${action} #{exp}`, `expected ${ordinalCall} "${spyName}" call to not ${action} #{exp}`, value, result?.value);
1632
1695
  });
1633
1696
  });
1634
1697
  // @ts-expect-error @internal
@@ -1647,7 +1710,7 @@ const JestChaiExpect = (chai, utils) => {
1647
1710
  if (utils.flag(this, "poll")) {
1648
1711
  throw new SyntaxError(`expect.poll() is not supported in combination with .resolves`);
1649
1712
  }
1650
- if (typeof (obj === null || obj === void 0 ? void 0 : obj.then) !== "function") {
1713
+ if (typeof obj?.then !== "function") {
1651
1714
  throw new TypeError(`You must provide a Promise to expect() when using .resolves, not '${typeof obj}'.`);
1652
1715
  }
1653
1716
  const proxy = new Proxy(this, { get: (target, key, receiver) => {
@@ -1657,14 +1720,18 @@ const JestChaiExpect = (chai, utils) => {
1657
1720
  }
1658
1721
  return (...args) => {
1659
1722
  utils.flag(this, "_name", key);
1660
- const promise = obj.then((value) => {
1723
+ const promise = Promise.resolve(obj).then((value) => {
1661
1724
  utils.flag(this, "object", value);
1662
1725
  return result.call(this, ...args);
1663
1726
  }, (err) => {
1664
1727
  const _error = new AssertionError(`promise rejected "${utils.inspect(err)}" instead of resolving`, { showDiff: false });
1665
1728
  _error.cause = err;
1666
- _error.stack = error.stack.replace(error.message, _error.message);
1667
1729
  throw _error;
1730
+ }).catch((err) => {
1731
+ if (isError(err) && error.stack) {
1732
+ err.stack = error.stack.replace(error.message, err.message);
1733
+ }
1734
+ throw err;
1668
1735
  });
1669
1736
  return recordAsyncExpect(test, promise, createAssertionMessage(utils, this, !!args.length), error);
1670
1737
  };
@@ -1681,7 +1748,7 @@ const JestChaiExpect = (chai, utils) => {
1681
1748
  if (utils.flag(this, "poll")) {
1682
1749
  throw new SyntaxError(`expect.poll() is not supported in combination with .rejects`);
1683
1750
  }
1684
- if (typeof (wrapper === null || wrapper === void 0 ? void 0 : wrapper.then) !== "function") {
1751
+ if (typeof wrapper?.then !== "function") {
1685
1752
  throw new TypeError(`You must provide a Promise to expect() when using .rejects, not '${typeof wrapper}'.`);
1686
1753
  }
1687
1754
  const proxy = new Proxy(this, { get: (target, key, receiver) => {
@@ -1691,17 +1758,21 @@ const JestChaiExpect = (chai, utils) => {
1691
1758
  }
1692
1759
  return (...args) => {
1693
1760
  utils.flag(this, "_name", key);
1694
- const promise = wrapper.then((value) => {
1761
+ const promise = Promise.resolve(wrapper).then((value) => {
1695
1762
  const _error = new AssertionError(`promise resolved "${utils.inspect(value)}" instead of rejecting`, {
1696
1763
  showDiff: true,
1697
1764
  expected: new Error("rejected promise"),
1698
1765
  actual: value
1699
1766
  });
1700
- _error.stack = error.stack.replace(error.message, _error.message);
1701
1767
  throw _error;
1702
1768
  }, (err) => {
1703
1769
  utils.flag(this, "object", err);
1704
1770
  return result.call(this, ...args);
1771
+ }).catch((err) => {
1772
+ if (isError(err) && error.stack) {
1773
+ err.stack = error.stack.replace(error.message, err.message);
1774
+ }
1775
+ throw err;
1705
1776
  });
1706
1777
  return recordAsyncExpect(test, promise, createAssertionMessage(utils, this, !!args.length), error);
1707
1778
  };
@@ -1709,24 +1780,10 @@ const JestChaiExpect = (chai, utils) => {
1709
1780
  return proxy;
1710
1781
  });
1711
1782
  };
1712
- function ordinalOf(i) {
1713
- const j = i % 10;
1714
- const k = i % 100;
1715
- if (j === 1 && k !== 11) {
1716
- return `${i}st`;
1717
- }
1718
- if (j === 2 && k !== 12) {
1719
- return `${i}nd`;
1720
- }
1721
- if (j === 3 && k !== 13) {
1722
- return `${i}rd`;
1723
- }
1724
- return `${i}th`;
1725
- }
1726
1783
  function formatCalls(spy, msg, showActualCall) {
1727
1784
  if (spy.mock.calls.length) {
1728
- msg += c.gray(`\n\nReceived: \n\n${spy.mock.calls.map((callArg, i) => {
1729
- let methodCall = c.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:\n\n`);
1785
+ msg += c.gray(`\n\nReceived:\n\n${spy.mock.calls.map((callArg, i) => {
1786
+ let methodCall = c.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`);
1730
1787
  if (showActualCall) {
1731
1788
  methodCall += diff(showActualCall, callArg, { omitAnnotationLines: true });
1732
1789
  } else {
@@ -1741,8 +1798,8 @@ function formatCalls(spy, msg, showActualCall) {
1741
1798
  }
1742
1799
  function formatReturns(spy, results, msg, showActualReturn) {
1743
1800
  if (results.length) {
1744
- msg += c.gray(`\n\nReceived: \n\n${results.map((callReturn, i) => {
1745
- let methodCall = c.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:\n\n`);
1801
+ msg += c.gray(`\n\nReceived:\n\n${results.map((callReturn, i) => {
1802
+ let methodCall = c.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call return:\n\n`);
1746
1803
  if (showActualReturn) {
1747
1804
  methodCall += diff(showActualReturn, callReturn.value, { omitAnnotationLines: true });
1748
1805
  } else {
@@ -1769,8 +1826,8 @@ function getMatcherState(assertion, expect) {
1769
1826
  subsetEquality
1770
1827
  };
1771
1828
  let task = util.flag(assertion, "vitest-test");
1772
- const currentTestName = (task === null || task === void 0 ? void 0 : task.fullTestName) ?? "";
1773
- if ((task === null || task === void 0 ? void 0 : task.type) !== "test") {
1829
+ const currentTestName = task?.fullTestName ?? "";
1830
+ if (task?.type !== "test") {
1774
1831
  task = undefined;
1775
1832
  }
1776
1833
  const matcherState = {
@@ -1872,4 +1929,4 @@ const JestExtend = (chai, utils) => {
1872
1929
  });
1873
1930
  };
1874
1931
 
1875
- export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, AsymmetricMatcher, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, ObjectContaining, SchemaMatching, StringContaining, StringMatching, addCustomEqualityTesters, arrayBufferEquality, customMatchers, equals, fnNameFor, generateToBeMessage, getObjectKeys, getObjectSubset, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isImmutableUnorderedKeyed, isImmutableUnorderedSet, isStandardSchema, iterableEquality, pluralize, setState, sparseArrayEquality, subsetEquality, typeEquality };
1932
+ export { ASYMMETRIC_MATCHERS_OBJECT, Any, Anything, ArrayContaining, AsymmetricMatcher, ChaiStyleAssertions, GLOBAL_EXPECT, JEST_MATCHERS_OBJECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, MATCHERS_OBJECT, ObjectContaining, SchemaMatching, StringContaining, StringMatching, addCustomEqualityTesters, arrayBufferEquality, createAssertionMessage, customMatchers, equals, fnNameFor, generateToBeMessage, getObjectKeys, getObjectSubset, getState, hasAsymmetric, hasProperty, isA, isAsymmetric, isError, isImmutableUnorderedKeyed, isImmutableUnorderedSet, isStandardSchema, iterableEquality, pluralize, recordAsyncExpect, setState, sparseArrayEquality, subsetEquality, typeEquality, wrapAssertion };
@@ -1,6 +1,7 @@
1
1
  import { M as ModuleMockerServerInterceptor } from './chunk-interceptor-native.js';
2
2
  import { registerModuleMocker } from './register.js';
3
3
  import './chunk-mocker.js';
4
+ import './chunk-helpers.js';
4
5
  import './index.js';
5
6
  import './chunk-registry.js';
6
7
  import './chunk-pathe.M-eThtNZ.js';
@@ -5,6 +5,7 @@ interface AutomockOptions {
5
5
  * @default "__vitest_mocker__"
6
6
  */
7
7
  globalThisAccessor?: string;
8
+ id?: string;
8
9
  }
9
10
  declare function automockModule(code: string, mockType: "automock" | "autospy", parse: (code: string) => any, options?: AutomockOptions): MagicString;
10
11
 
@@ -1 +1,6 @@
1
+ import 'node:fs';
2
+ import 'node:url';
1
3
  export { a as automockModule } from './chunk-automock.js';
4
+ import 'node:module';
5
+ import 'node:path';
6
+ import './chunk-helpers.js';
@@ -1,9 +1,9 @@
1
- import { M as ModuleMockerInterceptor } from './mocker.d-TnKRhz7N.js';
2
- export { C as CompilerHintsOptions, b as ModuleMocker, a as ModuleMockerCompilerHints, d as ModuleMockerConfig, e as ModuleMockerRPC, R as ResolveIdResult, f as ResolveMockResult, c as createCompilerHints } from './mocker.d-TnKRhz7N.js';
1
+ import { M as ModuleMockerInterceptor } from './mocker.d-QEntlm6J.js';
2
+ export { C as CompilerHintsOptions, b as ModuleMocker, a as ModuleMockerCompilerHints, c as ModuleMockerConfig, d as ModuleMockerRPC, R as ResolveIdResult, e as ResolveMockResult, f as createCompilerHints } from './mocker.d-QEntlm6J.js';
3
3
  import { StartOptions, SetupWorker } from 'msw/browser';
4
- import { M as MockerRegistry, a as MockedModule } from './types.d-B8CCKmHt.js';
4
+ import { M as MockerRegistry, a as MockedModule } from './types.d-BjI5eAwu.js';
5
5
  import '../spy/index.js';
6
- import './index.d-C-sLYZi-.js';
6
+ import './index.d-B41z0AuW.js';
7
7
 
8
8
  interface ModuleMockerMSWInterceptorOptions {
9
9
  /**
@@ -2,6 +2,7 @@ export { M as ModuleMocker, c as createCompilerHints } from './chunk-mocker.js';
2
2
  import { M as MockerRegistry } from './chunk-registry.js';
3
3
  import { c as createManualModuleSource, a as cleanUrl } from './chunk-utils.js';
4
4
  export { M as ModuleMockerServerInterceptor } from './chunk-interceptor-native.js';
5
+ import './chunk-helpers.js';
5
6
  import './index.js';
6
7
  import './chunk-pathe.M-eThtNZ.js';
7
8