@noma.to/qwik-testing-library 1.3.0 → 1.3.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 (85) hide show
  1. package/lib/lib/mock.qwik.cjs +3 -3
  2. package/lib/lib/mock.qwik.mjs +1 -1
  3. package/lib/lib/qwik-testing-library.qwik.cjs +2 -2
  4. package/lib/lib/qwik-testing-library.qwik.mjs +3 -3
  5. package/lib/lib/qwikloader.qwik.cjs +1 -1
  6. package/lib/lib/qwikloader.qwik.mjs +1 -1
  7. package/lib/node_modules/.pnpm/{@vitest_expect@2.1.8 → @vitest_expect@3.0.5}/node_modules/@vitest/expect/dist/index.qwik.cjs +175 -35
  8. package/lib/node_modules/.pnpm/{@vitest_expect@2.1.8 → @vitest_expect@3.0.5}/node_modules/@vitest/expect/dist/index.qwik.mjs +180 -40
  9. package/lib/node_modules/.pnpm/{@vitest_pretty-format@2.1.8 → @vitest_pretty-format@3.0.5}/node_modules/@vitest/pretty-format/dist/index.qwik.cjs +301 -10
  10. package/lib/node_modules/.pnpm/{@vitest_pretty-format@2.1.8 → @vitest_pretty-format@3.0.5}/node_modules/@vitest/pretty-format/dist/index.qwik.mjs +306 -15
  11. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/chunk-tasks.qwik.cjs +1 -1
  12. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/chunk-tasks.qwik.mjs +1 -1
  13. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/index.qwik.cjs +130 -44
  14. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/index.qwik.mjs +130 -44
  15. package/lib/node_modules/.pnpm/{@vitest_snapshot@2.1.8 → @vitest_snapshot@3.0.5}/node_modules/@vitest/snapshot/dist/index.qwik.cjs +119 -84
  16. package/lib/node_modules/.pnpm/{@vitest_snapshot@2.1.8 → @vitest_snapshot@3.0.5}/node_modules/@vitest/snapshot/dist/index.qwik.mjs +119 -84
  17. package/lib/node_modules/.pnpm/{@vitest_spy@2.1.8 → @vitest_spy@3.0.5}/node_modules/@vitest/spy/dist/index.qwik.cjs +20 -3
  18. package/lib/node_modules/.pnpm/{@vitest_spy@2.1.8 → @vitest_spy@3.0.5}/node_modules/@vitest/spy/dist/index.qwik.mjs +20 -3
  19. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.cjs +3 -3
  20. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.mjs +3 -3
  21. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/diff.qwik.cjs +37 -21
  22. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/diff.qwik.mjs +37 -21
  23. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/error.qwik.cjs +2 -2
  24. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/error.qwik.mjs +2 -2
  25. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/helpers.qwik.cjs +1 -1
  26. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/helpers.qwik.mjs +1 -1
  27. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/index.qwik.cjs +6 -4
  28. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/index.qwik.mjs +6 -4
  29. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/source-map.qwik.cjs +1 -1
  30. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/source-map.qwik.mjs +1 -1
  31. package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/index.qwik.mjs +6 -6
  32. package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/map.qwik.cjs +1 -3
  33. package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/map.qwik.mjs +1 -3
  34. package/lib/node_modules/.pnpm/{pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.qwik.cjs → pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.cjs} +2 -2
  35. package/lib/node_modules/.pnpm/{pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.qwik.mjs → pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.mjs} +2 -2
  36. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.cjs +4 -0
  37. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.mjs +5 -0
  38. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.cjs +1 -1
  39. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.mjs +1 -1
  40. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.DgezovHB.qwik.cjs → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.cjs} +439 -211
  41. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.DgezovHB.qwik.mjs → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.mjs} +415 -187
  42. package/package.json +8 -8
  43. package/lib/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/browser.qwik.cjs +0 -7
  44. package/lib/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/browser.qwik.mjs +0 -8
  45. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/arguments.qwik.cjs +0 -0
  46. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/arguments.qwik.mjs +0 -0
  47. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/array.qwik.cjs +0 -0
  48. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/array.qwik.mjs +0 -0
  49. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/bigint.qwik.cjs +0 -0
  50. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/bigint.qwik.mjs +0 -0
  51. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/class.qwik.cjs +0 -0
  52. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/class.qwik.mjs +0 -0
  53. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/date.qwik.cjs +0 -0
  54. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/date.qwik.mjs +0 -0
  55. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/error.qwik.cjs +0 -0
  56. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/error.qwik.mjs +0 -0
  57. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/function.qwik.cjs +0 -0
  58. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/function.qwik.mjs +0 -0
  59. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/helpers.qwik.cjs +0 -0
  60. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/helpers.qwik.mjs +0 -0
  61. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/html.qwik.cjs +0 -0
  62. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/html.qwik.mjs +0 -0
  63. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/index.qwik.cjs +0 -0
  64. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/number.qwik.cjs +0 -0
  65. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/number.qwik.mjs +0 -0
  66. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/object.qwik.cjs +0 -0
  67. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/object.qwik.mjs +0 -0
  68. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/promise.qwik.cjs +0 -0
  69. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/promise.qwik.mjs +0 -0
  70. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/regexp.qwik.cjs +0 -0
  71. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/regexp.qwik.mjs +0 -0
  72. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/set.qwik.cjs +0 -0
  73. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/set.qwik.mjs +0 -0
  74. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/string.qwik.cjs +0 -0
  75. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/string.qwik.mjs +0 -0
  76. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/symbol.qwik.cjs +0 -0
  77. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/symbol.qwik.mjs +0 -0
  78. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/typedarray.qwik.cjs +0 -0
  79. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/typedarray.qwik.mjs +0 -0
  80. /package/lib/node_modules/.pnpm/{tinyrainbow@1.2.0 → tinyrainbow@2.0.0}/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.cjs +0 -0
  81. /package/lib/node_modules/.pnpm/{tinyrainbow@1.2.0 → tinyrainbow@2.0.0}/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.mjs +0 -0
  82. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.cjs +0 -0
  83. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.mjs +0 -0
  84. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.cjs +0 -0
  85. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.mjs +0 -0
@@ -3,21 +3,21 @@ var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const index = require("../../../../../@vitest_expect@2.1.8/node_modules/@vitest/expect/dist/index.qwik.cjs");
7
- require("../../../../../@vitest_runner@2.1.8/node_modules/@vitest/runner/dist/index.qwik.cjs");
8
- const chunkTasks = require("../../../../../@vitest_runner@2.1.8/node_modules/@vitest/runner/dist/chunk-tasks.qwik.cjs");
9
- const index$3 = require("../../../../../@vitest_utils@2.1.8/node_modules/@vitest/utils/dist/index.qwik.cjs");
6
+ const index$2 = require("../../../../../@vitest_expect@3.0.5/node_modules/@vitest/expect/dist/index.qwik.cjs");
7
+ require("../../../../../@vitest_runner@3.0.5/node_modules/@vitest/runner/dist/index.qwik.cjs");
8
+ const chunkTasks = require("../../../../../@vitest_runner@3.0.5/node_modules/@vitest/runner/dist/chunk-tasks.qwik.cjs");
9
+ const index$1 = require("../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/index.qwik.cjs");
10
10
  const chai$1 = require("../../../../../chai@5.1.2/node_modules/chai/chai.qwik.cjs");
11
11
  const utils_C8RiOc4B = require("./utils.C8RiOc4B.qwik.cjs");
12
12
  const _commonjsHelpers_BFTU3MAI = require("./_commonjsHelpers.BFTU3MAI.qwik.cjs");
13
- const index$1 = require("../../../../../@vitest_snapshot@2.1.8/node_modules/@vitest/snapshot/dist/index.qwik.cjs");
14
- const sourceMap = require("../../../../../@vitest_utils@2.1.8/node_modules/@vitest/utils/dist/source-map.qwik.cjs");
13
+ const index$3 = require("../../../../../@vitest_snapshot@3.0.5/node_modules/@vitest/snapshot/dist/index.qwik.cjs");
14
+ const sourceMap = require("../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/source-map.qwik.cjs");
15
15
  const date_W2xKR2qe = require("./date.W2xKR2qe.qwik.cjs");
16
- const index$2 = require("../../../../../@vitest_spy@2.1.8/node_modules/@vitest/spy/dist/index.qwik.cjs");
17
- const helpers = require("../../../../../@vitest_utils@2.1.8/node_modules/@vitest/utils/dist/helpers.qwik.cjs");
16
+ const index = require("../../../../../@vitest_spy@3.0.5/node_modules/@vitest/spy/dist/index.qwik.cjs");
17
+ const helpers = require("../../../../../@vitest_utils@3.0.5/node_modules/@vitest/utils/dist/helpers.qwik.cjs");
18
18
  const unsupported = [
19
19
  // .poll is meant to retry matchers until they succeed, and
20
- // snapshots will always succeed as long as the poll method doesn't thow an error
20
+ // snapshots will always succeed as long as the poll method doesn't throw an error
21
21
  // in this case using the `vi.waitFor` method is more appropriate
22
22
  "matchSnapshot",
23
23
  "toMatchSnapshot",
@@ -70,19 +70,9 @@ function createExpectPoll(expect) {
70
70
  const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
71
71
  const promise = () => new Promise((resolve, reject) => {
72
72
  let intervalId;
73
+ let timeoutId;
73
74
  let lastError;
74
- const { setTimeout, clearTimeout } = index$3.getSafeTimers();
75
- const timeoutId = setTimeout(() => {
76
- clearTimeout(intervalId);
77
- reject(
78
- copyStackTrace$1(
79
- new Error(`Matcher did not succeed in ${timeout}ms`, {
80
- cause: lastError
81
- }),
82
- STACK_TRACE_ERROR
83
- )
84
- );
85
- }, timeout);
75
+ const { setTimeout, clearTimeout } = index$1.getSafeTimers();
86
76
  const check = async () => {
87
77
  try {
88
78
  chai$1.util.flag(assertion, "_name", key);
@@ -93,9 +83,26 @@ function createExpectPoll(expect) {
93
83
  clearTimeout(timeoutId);
94
84
  } catch (err) {
95
85
  lastError = err;
96
- intervalId = setTimeout(check, interval);
86
+ if (!chai$1.util.flag(assertion, "_isLastPollAttempt")) {
87
+ intervalId = setTimeout(check, interval);
88
+ }
97
89
  }
98
90
  };
91
+ timeoutId = setTimeout(() => {
92
+ clearTimeout(intervalId);
93
+ chai$1.util.flag(assertion, "_isLastPollAttempt", true);
94
+ const rejectWithCause = (cause) => {
95
+ reject(
96
+ copyStackTrace$1(
97
+ new Error(`Matcher did not succeed in ${timeout}ms`, {
98
+ cause
99
+ }),
100
+ STACK_TRACE_ERROR
101
+ )
102
+ );
103
+ };
104
+ check().then(() => rejectWithCause(lastError)).catch((e) => rejectWithCause(e));
105
+ }, timeout);
99
106
  check();
100
107
  });
101
108
  let awaited = false;
@@ -264,9 +271,9 @@ function recordAsyncExpect(_test, promise, assertion, error) {
264
271
  }
265
272
  });
266
273
  return {
267
- then(onFullfilled, onRejected) {
274
+ then(onFulfilled, onRejected) {
268
275
  resolved = true;
269
- return promise.then(onFullfilled, onRejected);
276
+ return promise.then(onFulfilled, onRejected);
270
277
  },
271
278
  catch(onRejected) {
272
279
  return promise.catch(onRejected);
@@ -282,9 +289,9 @@ function recordAsyncExpect(_test, promise, assertion, error) {
282
289
  let _client;
283
290
  function getSnapshotClient() {
284
291
  if (!_client) {
285
- _client = new index$1.SnapshotClient({
292
+ _client = new index$3.SnapshotClient({
286
293
  isEqual: (received, expected) => {
287
- return index.equals(received, expected, [index.iterableEquality, index.subsetEquality]);
294
+ return index$2.equals(received, expected, [index$2.iterableEquality, index$2.subsetEquality]);
288
295
  }
289
296
  });
290
297
  }
@@ -307,15 +314,20 @@ function getError(expected, promise) {
307
314
  throw new Error("snapshot function didn't throw");
308
315
  }
309
316
  function getTestNames(test) {
310
- if (!test) {
311
- return {};
312
- }
313
317
  return {
314
318
  filepath: test.file.filepath,
315
- name: chunkTasks.e(test).slice(1).join(" > ")
319
+ name: chunkTasks.f(test).slice(1).join(" > "),
320
+ testId: test.id
316
321
  };
317
322
  }
318
323
  const SnapshotPlugin = (chai2, utils) => {
324
+ function getTest(assertionName, obj) {
325
+ const test = utils.flag(obj, "vitest-test");
326
+ if (!test) {
327
+ throw new Error(`'${assertionName}' cannot be used without test context`);
328
+ }
329
+ return test;
330
+ }
319
331
  for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
320
332
  utils.addMethod(
321
333
  chai2.Assertion.prototype,
@@ -327,7 +339,7 @@ const SnapshotPlugin = (chai2, utils) => {
327
339
  throw new Error(`${key} cannot be used with "not"`);
328
340
  }
329
341
  const expected = utils.flag(this, "object");
330
- const test = utils.flag(this, "vitest-test");
342
+ const test = getTest(key, this);
331
343
  if (typeof properties === "string" && typeof message === "undefined") {
332
344
  message = properties;
333
345
  properties = void 0;
@@ -355,7 +367,7 @@ const SnapshotPlugin = (chai2, utils) => {
355
367
  }
356
368
  const error = new Error("resolves");
357
369
  const expected = utils.flag(this, "object");
358
- const test = utils.flag(this, "vitest-test");
370
+ const test = getTest("toMatchFileSnapshot", this);
359
371
  const errorMessage = utils.flag(this, "message");
360
372
  const promise = getSnapshotClient().assertRaw({
361
373
  received: expected,
@@ -384,8 +396,8 @@ const SnapshotPlugin = (chai2, utils) => {
384
396
  if (isNot) {
385
397
  throw new Error('toMatchInlineSnapshot cannot be used with "not"');
386
398
  }
387
- const test = utils.flag(this, "vitest-test");
388
- const isInsideEach = test && (test.each || test.suite?.each);
399
+ const test = getTest("toMatchInlineSnapshot", this);
400
+ const isInsideEach = test.each || test.suite?.each;
389
401
  if (isInsideEach) {
390
402
  throw new Error(
391
403
  "InlineSnapshot cannot be used inside of test.each or describe.each"
@@ -399,7 +411,7 @@ const SnapshotPlugin = (chai2, utils) => {
399
411
  properties = void 0;
400
412
  }
401
413
  if (inlineSnapshot) {
402
- inlineSnapshot = index$1.stripSnapshotIndentation(inlineSnapshot);
414
+ inlineSnapshot = index$3.stripSnapshotIndentation(inlineSnapshot);
403
415
  }
404
416
  const errorMessage = utils.flag(this, "message");
405
417
  getSnapshotClient().assert({
@@ -426,7 +438,7 @@ const SnapshotPlugin = (chai2, utils) => {
426
438
  );
427
439
  }
428
440
  const expected = utils.flag(this, "object");
429
- const test = utils.flag(this, "vitest-test");
441
+ const test = getTest("toThrowErrorMatchingSnapshot", this);
430
442
  const promise = utils.flag(this, "promise");
431
443
  const errorMessage = utils.flag(this, "message");
432
444
  getSnapshotClient().assert({
@@ -447,8 +459,8 @@ const SnapshotPlugin = (chai2, utils) => {
447
459
  'toThrowErrorMatchingInlineSnapshot cannot be used with "not"'
448
460
  );
449
461
  }
450
- const test = utils.flag(this, "vitest-test");
451
- const isInsideEach = test && (test.each || test.suite?.each);
462
+ const test = getTest("toThrowErrorMatchingInlineSnapshot", this);
463
+ const isInsideEach = test.each || test.suite?.each;
452
464
  if (isInsideEach) {
453
465
  throw new Error(
454
466
  "InlineSnapshot cannot be used inside of test.each or describe.each"
@@ -459,7 +471,7 @@ const SnapshotPlugin = (chai2, utils) => {
459
471
  const promise = utils.flag(this, "promise");
460
472
  const errorMessage = utils.flag(this, "message");
461
473
  if (inlineSnapshot) {
462
- inlineSnapshot = index$1.stripSnapshotIndentation(inlineSnapshot);
474
+ inlineSnapshot = index$3.stripSnapshotIndentation(inlineSnapshot);
463
475
  }
464
476
  getSnapshotClient().assert({
465
477
  received: getError(expected, promise),
@@ -472,28 +484,28 @@ const SnapshotPlugin = (chai2, utils) => {
472
484
  });
473
485
  }
474
486
  );
475
- utils.addMethod(chai2.expect, "addSnapshotSerializer", index$1.addSerializer);
487
+ utils.addMethod(chai2.expect, "addSnapshotSerializer", index$3.addSerializer);
476
488
  };
477
- chai$1.use(index.JestExtend);
478
- chai$1.use(index.JestChaiExpect);
489
+ chai$1.use(index$2.JestExtend);
490
+ chai$1.use(index$2.JestChaiExpect);
479
491
  chai$1.use(Subset);
480
492
  chai$1.use(SnapshotPlugin);
481
- chai$1.use(index.JestAsymmetricMatchers);
493
+ chai$1.use(index$2.JestAsymmetricMatchers);
482
494
  function createExpect(test) {
483
495
  const expect = (value, message) => {
484
- const { assertionCalls } = index.getState(expect);
485
- index.setState({ assertionCalls: assertionCalls + 1 }, expect);
496
+ const { assertionCalls } = index$2.getState(expect);
497
+ index$2.setState({ assertionCalls: assertionCalls + 1 }, expect);
486
498
  const assert2 = chai$1.expect(value, message);
487
499
  {
488
500
  return assert2;
489
501
  }
490
502
  };
491
503
  Object.assign(expect, chai$1.expect);
492
- Object.assign(expect, globalThis[index.ASYMMETRIC_MATCHERS_OBJECT]);
493
- expect.getState = () => index.getState(expect);
494
- expect.setState = (state) => index.setState(state, expect);
495
- const globalState = index.getState(globalThis[index.GLOBAL_EXPECT]) || {};
496
- index.setState(
504
+ Object.assign(expect, globalThis[index$2.ASYMMETRIC_MATCHERS_OBJECT]);
505
+ expect.getState = () => index$2.getState(expect);
506
+ expect.setState = (state) => index$2.setState(state, expect);
507
+ const globalState = index$2.getState(globalThis[index$2.GLOBAL_EXPECT]) || {};
508
+ index$2.setState(
497
509
  {
498
510
  // this should also add "snapshotState" that is added conditionally
499
511
  ...globalState,
@@ -511,7 +523,7 @@ function createExpect(test) {
511
523
  expect
512
524
  );
513
525
  expect.extend = (matchers) => chai$1.expect.extend(expect, matchers);
514
- expect.addEqualityTesters = (customTesters) => index.addCustomEqualityTesters(customTesters);
526
+ expect.addEqualityTesters = (customTesters) => index$2.addCustomEqualityTesters(customTesters);
515
527
  expect.soft = (...args) => {
516
528
  return expect(...args).withContext({ soft: true });
517
529
  };
@@ -545,10 +557,11 @@ function createExpect(test) {
545
557
  }
546
558
  chai$1.util.addMethod(expect, "assertions", assertions);
547
559
  chai$1.util.addMethod(expect, "hasAssertions", hasAssertions);
560
+ expect.extend(index$2.customMatchers);
548
561
  return expect;
549
562
  }
550
563
  const globalExpect = createExpect();
551
- Object.defineProperty(globalThis, index.GLOBAL_EXPECT, {
564
+ Object.defineProperty(globalThis, index$2.GLOBAL_EXPECT, {
552
565
  value: globalExpect,
553
566
  writable: true,
554
567
  configurable: true
@@ -660,42 +673,14 @@ function requireCalledInOrder() {
660
673
  calledInOrder_1 = calledInOrder;
661
674
  return calledInOrder_1;
662
675
  }
663
- var functionName;
664
- var hasRequiredFunctionName;
665
- function requireFunctionName() {
666
- if (hasRequiredFunctionName) return functionName;
667
- hasRequiredFunctionName = 1;
668
- functionName = function functionName2(func) {
669
- if (!func) {
670
- return "";
671
- }
672
- try {
673
- return func.displayName || func.name || // Use function decomposition as a last resort to get function
674
- // name. Does not rely on function decomposition to work - if it
675
- // doesn't debugging will be slightly less informative
676
- // (i.e. toString will say 'spy' rather than 'myFunc').
677
- (String(func).match(/function ([^\s(]+)/) || [])[1];
678
- } catch (e) {
679
- return "";
680
- }
681
- };
682
- return functionName;
683
- }
684
676
  var className_1;
685
677
  var hasRequiredClassName;
686
678
  function requireClassName() {
687
679
  if (hasRequiredClassName) return className_1;
688
680
  hasRequiredClassName = 1;
689
- var functionName2 = requireFunctionName();
690
681
  function className(value) {
691
- return value.constructor && value.constructor.name || // The next branch is for IE11 support only:
692
- // Because the name property is not set on the prototype
693
- // of the Function object, we finally try to grab the
694
- // name from its definition. This will never be reached
695
- // in node, so we are not able to test this properly.
696
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
697
- typeof value.constructor === "function" && /* istanbul ignore next */
698
- functionName2(value.constructor) || null;
682
+ const name = value.constructor && value.constructor.name;
683
+ return name || null;
699
684
  }
700
685
  className_1 = className;
701
686
  return className_1;
@@ -751,6 +736,27 @@ function requireEvery() {
751
736
  };
752
737
  return every;
753
738
  }
739
+ var functionName;
740
+ var hasRequiredFunctionName;
741
+ function requireFunctionName() {
742
+ if (hasRequiredFunctionName) return functionName;
743
+ hasRequiredFunctionName = 1;
744
+ functionName = function functionName2(func) {
745
+ if (!func) {
746
+ return "";
747
+ }
748
+ try {
749
+ return func.displayName || func.name || // Use function decomposition as a last resort to get function
750
+ // name. Does not rely on function decomposition to work - if it
751
+ // doesn't debugging will be slightly less informative
752
+ // (i.e. toString will say 'spy' rather than 'myFunc').
753
+ (String(func).match(/function ([^\s(]+)/) || [])[1];
754
+ } catch (e) {
755
+ return "";
756
+ }
757
+ };
758
+ return functionName;
759
+ }
754
760
  var orderByFirstCall_1;
755
761
  var hasRequiredOrderByFirstCall;
756
762
  function requireOrderByFirstCall() {
@@ -1002,12 +1008,16 @@ function requireFakeTimersSrc() {
1002
1008
  if (hasRequiredFakeTimersSrc) return fakeTimersSrc;
1003
1009
  hasRequiredFakeTimersSrc = 1;
1004
1010
  const globalObject = requireLib().global;
1005
- let timersModule;
1011
+ let timersModule, timersPromisesModule;
1006
1012
  if (typeof __vitest_required__ !== "undefined") {
1007
1013
  try {
1008
1014
  timersModule = __vitest_required__.timers;
1009
1015
  } catch (e) {
1010
1016
  }
1017
+ try {
1018
+ timersPromisesModule = __vitest_required__.timersPromises;
1019
+ } catch (e) {
1020
+ }
1011
1021
  }
1012
1022
  function withGlobal(_global) {
1013
1023
  const maxTimeout = Math.pow(2, 31) - 1;
@@ -1018,26 +1028,57 @@ function requireFakeTimersSrc() {
1018
1028
  const NOOP_ARRAY = function() {
1019
1029
  return [];
1020
1030
  };
1021
- const timeoutResult = _global.setTimeout(NOOP, 0);
1022
- const addTimerReturnsObject = typeof timeoutResult === "object";
1023
- const hrtimePresent = _global.process && typeof _global.process.hrtime === "function";
1024
- const hrtimeBigintPresent = hrtimePresent && typeof _global.process.hrtime.bigint === "function";
1025
- const nextTickPresent = _global.process && typeof _global.process.nextTick === "function";
1031
+ const isPresent = {};
1032
+ let timeoutResult, addTimerReturnsObject = false;
1033
+ if (_global.setTimeout) {
1034
+ isPresent.setTimeout = true;
1035
+ timeoutResult = _global.setTimeout(NOOP, 0);
1036
+ addTimerReturnsObject = typeof timeoutResult === "object";
1037
+ }
1038
+ isPresent.clearTimeout = Boolean(_global.clearTimeout);
1039
+ isPresent.setInterval = Boolean(_global.setInterval);
1040
+ isPresent.clearInterval = Boolean(_global.clearInterval);
1041
+ isPresent.hrtime = _global.process && typeof _global.process.hrtime === "function";
1042
+ isPresent.hrtimeBigint = isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
1043
+ isPresent.nextTick = _global.process && typeof _global.process.nextTick === "function";
1026
1044
  const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
1027
- const performancePresent = _global.performance && typeof _global.performance.now === "function";
1045
+ isPresent.performance = _global.performance && typeof _global.performance.now === "function";
1028
1046
  const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
1029
1047
  const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
1030
- const queueMicrotaskPresent = _global.hasOwnProperty("queueMicrotask");
1031
- const requestAnimationFramePresent = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
1032
- const cancelAnimationFramePresent = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
1033
- const requestIdleCallbackPresent = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
1034
- const cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
1035
- const setImmediatePresent = _global.setImmediate && typeof _global.setImmediate === "function";
1036
- const intlPresent = _global.Intl && typeof _global.Intl === "object";
1037
- _global.clearTimeout(timeoutResult);
1048
+ isPresent.queueMicrotask = _global.hasOwnProperty("queueMicrotask");
1049
+ isPresent.requestAnimationFrame = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
1050
+ isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
1051
+ isPresent.requestIdleCallback = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
1052
+ isPresent.cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
1053
+ isPresent.setImmediate = _global.setImmediate && typeof _global.setImmediate === "function";
1054
+ isPresent.clearImmediate = _global.clearImmediate && typeof _global.clearImmediate === "function";
1055
+ isPresent.Intl = _global.Intl && typeof _global.Intl === "object";
1056
+ if (_global.clearTimeout) {
1057
+ _global.clearTimeout(timeoutResult);
1058
+ }
1038
1059
  const NativeDate = _global.Date;
1039
- const NativeIntl = _global.Intl;
1060
+ const NativeIntl = isPresent.Intl ? Object.defineProperties(
1061
+ /* @__PURE__ */ Object.create(null),
1062
+ Object.getOwnPropertyDescriptors(_global.Intl)
1063
+ ) : void 0;
1040
1064
  let uniqueTimerId = idCounterStart;
1065
+ if (NativeDate === void 0) {
1066
+ throw new Error(
1067
+ "The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)"
1068
+ );
1069
+ }
1070
+ isPresent.Date = true;
1071
+ class FakePerformanceEntry {
1072
+ constructor(name, entryType, startTime, duration) {
1073
+ this.name = name;
1074
+ this.entryType = entryType;
1075
+ this.startTime = startTime;
1076
+ this.duration = duration;
1077
+ }
1078
+ toJSON() {
1079
+ return JSON.stringify({ ...this });
1080
+ }
1081
+ }
1041
1082
  function isNumberFinite(num) {
1042
1083
  if (Number.isFinite) {
1043
1084
  return Number.isFinite(num);
@@ -1138,80 +1179,66 @@ ${job.error.stack.split("\n").slice(matchedLineIndex + 1).join("\n")}`;
1138
1179
  }
1139
1180
  return infiniteLoopError;
1140
1181
  }
1141
- function mirrorDateProperties(target, source) {
1142
- let prop;
1143
- for (prop in source) {
1144
- if (source.hasOwnProperty(prop)) {
1145
- target[prop] = source[prop];
1182
+ function createDate() {
1183
+ class ClockDate extends NativeDate {
1184
+ /**
1185
+ * @param {number} year
1186
+ * @param {number} month
1187
+ * @param {number} date
1188
+ * @param {number} hour
1189
+ * @param {number} minute
1190
+ * @param {number} second
1191
+ * @param {number} ms
1192
+ * @returns void
1193
+ */
1194
+ // eslint-disable-next-line no-unused-vars
1195
+ constructor(year, month, date, hour, minute, second, ms) {
1196
+ if (arguments.length === 0) {
1197
+ super(ClockDate.clock.now);
1198
+ } else {
1199
+ super(...arguments);
1200
+ }
1201
+ Object.defineProperty(this, "constructor", {
1202
+ value: NativeDate,
1203
+ enumerable: false
1204
+ });
1205
+ }
1206
+ static [Symbol.hasInstance](instance) {
1207
+ return instance instanceof NativeDate;
1146
1208
  }
1147
1209
  }
1148
- if (source.now) {
1149
- target.now = function now() {
1150
- return target.clock.now;
1210
+ ClockDate.isFake = true;
1211
+ if (NativeDate.now) {
1212
+ ClockDate.now = function now() {
1213
+ return ClockDate.clock.now;
1151
1214
  };
1152
- } else {
1153
- delete target.now;
1154
1215
  }
1155
- if (source.toSource) {
1156
- target.toSource = function toSource() {
1157
- return source.toSource();
1216
+ if (NativeDate.toSource) {
1217
+ ClockDate.toSource = function toSource() {
1218
+ return NativeDate.toSource();
1158
1219
  };
1159
- } else {
1160
- delete target.toSource;
1161
1220
  }
1162
- target.toString = function toString() {
1163
- return source.toString();
1221
+ ClockDate.toString = function toString() {
1222
+ return NativeDate.toString();
1164
1223
  };
1165
- target.prototype = source.prototype;
1166
- target.parse = source.parse;
1167
- target.UTC = source.UTC;
1168
- target.prototype.toUTCString = source.prototype.toUTCString;
1169
- target.isFake = true;
1170
- return target;
1171
- }
1172
- function createDate() {
1173
- function ClockDate(year, month, date, hour, minute, second, ms) {
1174
- if (!(this instanceof ClockDate)) {
1175
- return new NativeDate(ClockDate.clock.now).toString();
1176
- }
1177
- switch (arguments.length) {
1178
- case 0:
1179
- return new NativeDate(ClockDate.clock.now);
1180
- case 1:
1181
- return new NativeDate(year);
1182
- case 2:
1183
- return new NativeDate(year, month);
1184
- case 3:
1185
- return new NativeDate(year, month, date);
1186
- case 4:
1187
- return new NativeDate(year, month, date, hour);
1188
- case 5:
1189
- return new NativeDate(year, month, date, hour, minute);
1190
- case 6:
1191
- return new NativeDate(
1192
- year,
1193
- month,
1194
- date,
1195
- hour,
1196
- minute,
1197
- second
1198
- );
1199
- default:
1200
- return new NativeDate(
1201
- year,
1202
- month,
1203
- date,
1204
- hour,
1205
- minute,
1206
- second,
1207
- ms
1224
+ const ClockDateProxy = new Proxy(ClockDate, {
1225
+ // handler for [[Call]] invocations (i.e. not using `new`)
1226
+ apply() {
1227
+ if (this instanceof ClockDate) {
1228
+ throw new TypeError(
1229
+ "A Proxy should only capture `new` calls with the `construct` handler. This is not supposed to be possible, so check the logic."
1208
1230
  );
1231
+ }
1232
+ return new NativeDate(ClockDate.clock.now).toString();
1209
1233
  }
1210
- }
1211
- return mirrorDateProperties(ClockDate, NativeDate);
1234
+ });
1235
+ return ClockDateProxy;
1212
1236
  }
1213
1237
  function createIntl() {
1214
- const ClockIntl = { ...NativeIntl };
1238
+ const ClockIntl = {};
1239
+ Object.getOwnPropertyNames(NativeIntl).forEach(
1240
+ (property) => ClockIntl[property] = NativeIntl[property]
1241
+ );
1215
1242
  ClockIntl.DateTimeFormat = function(...args) {
1216
1243
  const realFormatter = new NativeIntl.DateTimeFormat(...args);
1217
1244
  const formatter = {};
@@ -1497,11 +1524,21 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1497
1524
  timersModule[entry.methodName] = entry.original;
1498
1525
  }
1499
1526
  }
1527
+ if (clock.timersPromisesModuleMethods !== void 0) {
1528
+ for (let j = 0; j < clock.timersPromisesModuleMethods.length; j++) {
1529
+ const entry = clock.timersPromisesModuleMethods[j];
1530
+ timersPromisesModule[entry.methodName] = entry.original;
1531
+ }
1532
+ }
1500
1533
  }
1501
1534
  if (config.shouldAdvanceTime === true) {
1502
1535
  _global.clearInterval(clock.attachedInterval);
1503
1536
  }
1504
1537
  clock.methods = [];
1538
+ for (const [listener, signal] of clock.abortListenerMap.entries()) {
1539
+ signal.removeEventListener("abort", listener);
1540
+ clock.abortListenerMap.delete(listener);
1541
+ }
1505
1542
  if (!clock.timers) {
1506
1543
  return [];
1507
1544
  }
@@ -1516,8 +1553,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1516
1553
  );
1517
1554
  clock[`_${method}`] = target[method];
1518
1555
  if (method === "Date") {
1519
- const date = mirrorDateProperties(clock[method], target[method]);
1520
- target[method] = date;
1556
+ target[method] = clock[method];
1521
1557
  } else if (method === "Intl") {
1522
1558
  target[method] = clock[method];
1523
1559
  } else if (method === "performance") {
@@ -1560,36 +1596,38 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1560
1596
  clearInterval: _global.clearInterval,
1561
1597
  Date: _global.Date
1562
1598
  };
1563
- if (setImmediatePresent) {
1599
+ if (isPresent.setImmediate) {
1564
1600
  timers.setImmediate = _global.setImmediate;
1601
+ }
1602
+ if (isPresent.clearImmediate) {
1565
1603
  timers.clearImmediate = _global.clearImmediate;
1566
1604
  }
1567
- if (hrtimePresent) {
1605
+ if (isPresent.hrtime) {
1568
1606
  timers.hrtime = _global.process.hrtime;
1569
1607
  }
1570
- if (nextTickPresent) {
1608
+ if (isPresent.nextTick) {
1571
1609
  timers.nextTick = _global.process.nextTick;
1572
1610
  }
1573
- if (performancePresent) {
1611
+ if (isPresent.performance) {
1574
1612
  timers.performance = _global.performance;
1575
1613
  }
1576
- if (requestAnimationFramePresent) {
1614
+ if (isPresent.requestAnimationFrame) {
1577
1615
  timers.requestAnimationFrame = _global.requestAnimationFrame;
1578
1616
  }
1579
- if (queueMicrotaskPresent) {
1580
- timers.queueMicrotask = true;
1617
+ if (isPresent.queueMicrotask) {
1618
+ timers.queueMicrotask = _global.queueMicrotask;
1581
1619
  }
1582
- if (cancelAnimationFramePresent) {
1620
+ if (isPresent.cancelAnimationFrame) {
1583
1621
  timers.cancelAnimationFrame = _global.cancelAnimationFrame;
1584
1622
  }
1585
- if (requestIdleCallbackPresent) {
1623
+ if (isPresent.requestIdleCallback) {
1586
1624
  timers.requestIdleCallback = _global.requestIdleCallback;
1587
1625
  }
1588
- if (cancelIdleCallbackPresent) {
1626
+ if (isPresent.cancelIdleCallback) {
1589
1627
  timers.cancelIdleCallback = _global.cancelIdleCallback;
1590
1628
  }
1591
- if (intlPresent) {
1592
- timers.Intl = _global.Intl;
1629
+ if (isPresent.Intl) {
1630
+ timers.Intl = NativeIntl;
1593
1631
  }
1594
1632
  const originalSetTimeout = _global.setImmediate || _global.setTimeout;
1595
1633
  function createClock(start, loopLimit) {
@@ -1597,11 +1635,6 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1597
1635
  loopLimit = loopLimit || 1e3;
1598
1636
  let nanos = 0;
1599
1637
  const adjustedSystemTime = [0, 0];
1600
- if (NativeDate === void 0) {
1601
- throw new Error(
1602
- "The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)"
1603
- );
1604
- }
1605
1638
  const clock = {
1606
1639
  now: start,
1607
1640
  Date: createDate(),
@@ -1637,13 +1670,13 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1637
1670
  const millis = hrt[0] * 1e3 + hrt[1] / 1e6;
1638
1671
  return millis;
1639
1672
  }
1640
- if (hrtimeBigintPresent) {
1673
+ if (isPresent.hrtimeBigint) {
1641
1674
  hrtime.bigint = function() {
1642
1675
  const parts = hrtime();
1643
1676
  return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]);
1644
1677
  };
1645
1678
  }
1646
- if (intlPresent) {
1679
+ if (isPresent.Intl) {
1647
1680
  clock.Intl = createIntl();
1648
1681
  clock.Intl.clock = clock;
1649
1682
  }
@@ -1706,7 +1739,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1706
1739
  clock.clearInterval = function clearInterval(timerId) {
1707
1740
  return clearTimer(clock, timerId, "Interval");
1708
1741
  };
1709
- if (setImmediatePresent) {
1742
+ if (isPresent.setImmediate) {
1710
1743
  clock.setImmediate = function setImmediate(func) {
1711
1744
  return addTimer(clock, {
1712
1745
  func,
@@ -1939,6 +1972,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1939
1972
  function doRun() {
1940
1973
  originalSetTimeout(function() {
1941
1974
  try {
1975
+ runJobs(clock);
1942
1976
  let numTimers;
1943
1977
  if (i < clock.loopLimit) {
1944
1978
  if (!clock.timers) {
@@ -1986,6 +2020,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
1986
2020
  try {
1987
2021
  const timer = lastTimer(clock);
1988
2022
  if (!timer) {
2023
+ runJobs(clock);
1989
2024
  resolve(clock.now);
1990
2025
  }
1991
2026
  resolve(clock.tickAsync(timer.callAt - clock.now));
@@ -2028,11 +2063,11 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
2028
2063
  }
2029
2064
  clock.tick(ms);
2030
2065
  };
2031
- if (performancePresent) {
2066
+ if (isPresent.performance) {
2032
2067
  clock.performance = /* @__PURE__ */ Object.create(null);
2033
2068
  clock.performance.now = fakePerformanceNow;
2034
2069
  }
2035
- if (hrtimePresent) {
2070
+ if (isPresent.hrtime) {
2036
2071
  clock.hrtime = hrtime;
2037
2072
  }
2038
2073
  return clock;
@@ -2059,17 +2094,24 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
2059
2094
  "config.target is no longer supported. Use `withGlobal(target)` instead."
2060
2095
  );
2061
2096
  }
2097
+ function handleMissingTimer(timer) {
2098
+ if (config.ignoreMissingTimers) {
2099
+ return;
2100
+ }
2101
+ throw new ReferenceError(
2102
+ `non-existent timers and/or objects cannot be faked: '${timer}'`
2103
+ );
2104
+ }
2062
2105
  let i, l;
2063
2106
  const clock = createClock(config.now, config.loopLimit);
2064
2107
  clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
2065
2108
  clock.uninstall = function() {
2066
2109
  return uninstall(clock, config);
2067
2110
  };
2111
+ clock.abortListenerMap = /* @__PURE__ */ new Map();
2068
2112
  clock.methods = config.toFake || [];
2069
2113
  if (clock.methods.length === 0) {
2070
- clock.methods = Object.keys(timers).filter(function(key) {
2071
- return key !== "nextTick" && key !== "queueMicrotask";
2072
- });
2114
+ clock.methods = Object.keys(timers);
2073
2115
  }
2074
2116
  if (config.shouldAdvanceTime === true) {
2075
2117
  const intervalTick = doIntervalTick.bind(
@@ -2098,17 +2140,25 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
2098
2140
  clock.performance[name] = name.indexOf("getEntries") === 0 ? NOOP_ARRAY : NOOP;
2099
2141
  }
2100
2142
  });
2143
+ clock.performance.mark = (name) => new FakePerformanceEntry(name, "mark", 0, 0);
2144
+ clock.performance.measure = (name) => new FakePerformanceEntry(name, "measure", 0, 100);
2145
+ clock.performance.timeOrigin = getEpoch(config.now);
2101
2146
  } else if ((config.toFake || []).includes("performance")) {
2102
- throw new ReferenceError(
2103
- "non-existent performance object cannot be faked"
2104
- );
2147
+ return handleMissingTimer("performance");
2105
2148
  }
2106
2149
  }
2107
2150
  if (_global === globalObject && timersModule) {
2108
2151
  clock.timersModuleMethods = [];
2109
2152
  }
2153
+ if (_global === globalObject && timersPromisesModule) {
2154
+ clock.timersPromisesModuleMethods = [];
2155
+ }
2110
2156
  for (i = 0, l = clock.methods.length; i < l; i++) {
2111
2157
  const nameOfMethodToReplace = clock.methods[i];
2158
+ if (!isPresent[nameOfMethodToReplace]) {
2159
+ handleMissingTimer(nameOfMethodToReplace);
2160
+ continue;
2161
+ }
2112
2162
  if (nameOfMethodToReplace === "hrtime") {
2113
2163
  if (_global.process && typeof _global.process.hrtime === "function") {
2114
2164
  hijackMethod(_global.process, nameOfMethodToReplace, clock);
@@ -2128,6 +2178,194 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
2128
2178
  });
2129
2179
  timersModule[nameOfMethodToReplace] = _global[nameOfMethodToReplace];
2130
2180
  }
2181
+ if (clock.timersPromisesModuleMethods !== void 0) {
2182
+ if (nameOfMethodToReplace === "setTimeout") {
2183
+ clock.timersPromisesModuleMethods.push({
2184
+ methodName: "setTimeout",
2185
+ original: timersPromisesModule.setTimeout
2186
+ });
2187
+ timersPromisesModule.setTimeout = (delay, value, options = {}) => new Promise((resolve, reject) => {
2188
+ const abort = () => {
2189
+ options.signal.removeEventListener(
2190
+ "abort",
2191
+ abort
2192
+ );
2193
+ clock.abortListenerMap.delete(abort);
2194
+ clock.clearTimeout(handle);
2195
+ reject(options.signal.reason);
2196
+ };
2197
+ const handle = clock.setTimeout(() => {
2198
+ if (options.signal) {
2199
+ options.signal.removeEventListener(
2200
+ "abort",
2201
+ abort
2202
+ );
2203
+ clock.abortListenerMap.delete(abort);
2204
+ }
2205
+ resolve(value);
2206
+ }, delay);
2207
+ if (options.signal) {
2208
+ if (options.signal.aborted) {
2209
+ abort();
2210
+ } else {
2211
+ options.signal.addEventListener(
2212
+ "abort",
2213
+ abort
2214
+ );
2215
+ clock.abortListenerMap.set(
2216
+ abort,
2217
+ options.signal
2218
+ );
2219
+ }
2220
+ }
2221
+ });
2222
+ } else if (nameOfMethodToReplace === "setImmediate") {
2223
+ clock.timersPromisesModuleMethods.push({
2224
+ methodName: "setImmediate",
2225
+ original: timersPromisesModule.setImmediate
2226
+ });
2227
+ timersPromisesModule.setImmediate = (value, options = {}) => new Promise((resolve, reject) => {
2228
+ const abort = () => {
2229
+ options.signal.removeEventListener(
2230
+ "abort",
2231
+ abort
2232
+ );
2233
+ clock.abortListenerMap.delete(abort);
2234
+ clock.clearImmediate(handle);
2235
+ reject(options.signal.reason);
2236
+ };
2237
+ const handle = clock.setImmediate(() => {
2238
+ if (options.signal) {
2239
+ options.signal.removeEventListener(
2240
+ "abort",
2241
+ abort
2242
+ );
2243
+ clock.abortListenerMap.delete(abort);
2244
+ }
2245
+ resolve(value);
2246
+ });
2247
+ if (options.signal) {
2248
+ if (options.signal.aborted) {
2249
+ abort();
2250
+ } else {
2251
+ options.signal.addEventListener(
2252
+ "abort",
2253
+ abort
2254
+ );
2255
+ clock.abortListenerMap.set(
2256
+ abort,
2257
+ options.signal
2258
+ );
2259
+ }
2260
+ }
2261
+ });
2262
+ } else if (nameOfMethodToReplace === "setInterval") {
2263
+ clock.timersPromisesModuleMethods.push({
2264
+ methodName: "setInterval",
2265
+ original: timersPromisesModule.setInterval
2266
+ });
2267
+ timersPromisesModule.setInterval = (delay, value, options = {}) => ({
2268
+ [Symbol.asyncIterator]: () => {
2269
+ const createResolvable = () => {
2270
+ let resolve, reject;
2271
+ const promise = new Promise((res, rej) => {
2272
+ resolve = res;
2273
+ reject = rej;
2274
+ });
2275
+ promise.resolve = resolve;
2276
+ promise.reject = reject;
2277
+ return promise;
2278
+ };
2279
+ let done = false;
2280
+ let hasThrown = false;
2281
+ let returnCall;
2282
+ let nextAvailable = 0;
2283
+ const nextQueue = [];
2284
+ const handle = clock.setInterval(() => {
2285
+ if (nextQueue.length > 0) {
2286
+ nextQueue.shift().resolve();
2287
+ } else {
2288
+ nextAvailable++;
2289
+ }
2290
+ }, delay);
2291
+ const abort = () => {
2292
+ options.signal.removeEventListener(
2293
+ "abort",
2294
+ abort
2295
+ );
2296
+ clock.abortListenerMap.delete(abort);
2297
+ clock.clearInterval(handle);
2298
+ done = true;
2299
+ for (const resolvable of nextQueue) {
2300
+ resolvable.resolve();
2301
+ }
2302
+ };
2303
+ if (options.signal) {
2304
+ if (options.signal.aborted) {
2305
+ done = true;
2306
+ } else {
2307
+ options.signal.addEventListener(
2308
+ "abort",
2309
+ abort
2310
+ );
2311
+ clock.abortListenerMap.set(
2312
+ abort,
2313
+ options.signal
2314
+ );
2315
+ }
2316
+ }
2317
+ return {
2318
+ next: async () => {
2319
+ if (options.signal?.aborted && !hasThrown) {
2320
+ hasThrown = true;
2321
+ throw options.signal.reason;
2322
+ }
2323
+ if (done) {
2324
+ return { done: true, value: void 0 };
2325
+ }
2326
+ if (nextAvailable > 0) {
2327
+ nextAvailable--;
2328
+ return { done: false, value };
2329
+ }
2330
+ const resolvable = createResolvable();
2331
+ nextQueue.push(resolvable);
2332
+ await resolvable;
2333
+ if (returnCall && nextQueue.length === 0) {
2334
+ returnCall.resolve();
2335
+ }
2336
+ if (options.signal?.aborted && !hasThrown) {
2337
+ hasThrown = true;
2338
+ throw options.signal.reason;
2339
+ }
2340
+ if (done) {
2341
+ return { done: true, value: void 0 };
2342
+ }
2343
+ return { done: false, value };
2344
+ },
2345
+ return: async () => {
2346
+ if (done) {
2347
+ return { done: true, value: void 0 };
2348
+ }
2349
+ if (nextQueue.length > 0) {
2350
+ returnCall = createResolvable();
2351
+ await returnCall;
2352
+ }
2353
+ clock.clearInterval(handle);
2354
+ done = true;
2355
+ if (options.signal) {
2356
+ options.signal.removeEventListener(
2357
+ "abort",
2358
+ abort
2359
+ );
2360
+ clock.abortListenerMap.delete(abort);
2361
+ }
2362
+ return { done: true, value: void 0 };
2363
+ }
2364
+ };
2365
+ }
2366
+ });
2367
+ }
2368
+ }
2131
2369
  }
2132
2370
  return clock;
2133
2371
  }
@@ -2259,21 +2497,11 @@ class FakeTimers {
2259
2497
  "process.nextTick cannot be mocked inside child_process"
2260
2498
  );
2261
2499
  }
2262
- const existingFakedMethods = (this._userConfig?.toFake || toFake).filter(
2263
- (method) => {
2264
- switch (method) {
2265
- case "setImmediate":
2266
- case "clearImmediate":
2267
- return method in this._global && this._global[method];
2268
- default:
2269
- return true;
2270
- }
2271
- }
2272
- );
2273
2500
  this._clock = this._fakeTimers.install({
2274
2501
  now: Date.now(),
2275
2502
  ...this._userConfig,
2276
- toFake: existingFakedMethods
2503
+ toFake: this._userConfig?.toFake || toFake,
2504
+ ignoreMissingTimers: true
2277
2505
  });
2278
2506
  this._fakingTime = true;
2279
2507
  }
@@ -2324,7 +2552,7 @@ function copyStackTrace(target, source) {
2324
2552
  return target;
2325
2553
  }
2326
2554
  function waitFor(callback, options = {}) {
2327
- const { setTimeout, setInterval, clearTimeout, clearInterval } = index$3.getSafeTimers();
2555
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = index$1.getSafeTimers();
2328
2556
  const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2329
2557
  const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
2330
2558
  return new Promise((resolve, reject) => {
@@ -2392,7 +2620,7 @@ function waitFor(callback, options = {}) {
2392
2620
  });
2393
2621
  }
2394
2622
  function waitUntil(callback, options = {}) {
2395
- const { setTimeout, setInterval, clearTimeout, clearInterval } = index$3.getSafeTimers();
2623
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = index$1.getSafeTimers();
2396
2624
  const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2397
2625
  const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
2398
2626
  return new Promise((resolve, reject) => {
@@ -2557,8 +2785,8 @@ function createVitest() {
2557
2785
  return utils;
2558
2786
  },
2559
2787
  // mocks
2560
- spyOn: index$2.spyOn,
2561
- fn: index$2.fn,
2788
+ spyOn: index.spyOn,
2789
+ fn: index.fn,
2562
2790
  waitFor,
2563
2791
  waitUntil,
2564
2792
  hoisted(factory) {
@@ -2634,18 +2862,18 @@ function createVitest() {
2634
2862
  return item;
2635
2863
  },
2636
2864
  isMockFunction(fn2) {
2637
- return index$2.isMockFunction(fn2);
2865
+ return index.isMockFunction(fn2);
2638
2866
  },
2639
2867
  clearAllMocks() {
2640
- index$2.mocks.forEach((spy) => spy.mockClear());
2868
+ index.mocks.forEach((spy) => spy.mockClear());
2641
2869
  return utils;
2642
2870
  },
2643
2871
  resetAllMocks() {
2644
- index$2.mocks.forEach((spy) => spy.mockReset());
2872
+ index.mocks.forEach((spy) => spy.mockReset());
2645
2873
  return utils;
2646
2874
  },
2647
2875
  restoreAllMocks() {
2648
- index$2.mocks.forEach((spy) => spy.mockRestore());
2876
+ index.mocks.forEach((spy) => spy.mockRestore());
2649
2877
  return utils;
2650
2878
  },
2651
2879
  stubGlobal(name, value) {