sunpeak 0.19.12 → 0.20.2

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/README.md +2 -2
  2. package/bin/commands/inspect.mjs +361 -12
  3. package/bin/commands/test-init.mjs +190 -118
  4. package/bin/commands/test.mjs +12 -1
  5. package/bin/lib/eval/eval-runner.mjs +7 -1
  6. package/bin/lib/inspect/inspect-config.mjs +17 -2
  7. package/bin/lib/inspect/inspect-server.d.mts +32 -0
  8. package/bin/lib/inspect/inspect-server.mjs +11 -0
  9. package/bin/lib/live/live-config.d.mts +10 -0
  10. package/bin/lib/live/live-config.mjs +34 -2
  11. package/bin/lib/resolve-bin.mjs +39 -0
  12. package/bin/lib/test/base-config.mjs +6 -3
  13. package/bin/lib/test/matchers.mjs +2 -2
  14. package/bin/lib/test/test-config.mjs +19 -8
  15. package/bin/lib/test/test-fixtures.d.mts +52 -92
  16. package/bin/lib/test/test-fixtures.mjs +174 -147
  17. package/dist/chatgpt/index.cjs +1 -1
  18. package/dist/chatgpt/index.js +1 -1
  19. package/dist/claude/index.cjs +1 -1
  20. package/dist/claude/index.js +1 -1
  21. package/dist/host/chatgpt/index.cjs +1 -1
  22. package/dist/host/chatgpt/index.js +1 -1
  23. package/dist/index.cjs +4 -4
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +3 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/inspector/index.cjs +1 -1
  28. package/dist/inspector/index.js +1 -1
  29. package/dist/{inspector-D5DckQuU.js → inspector-BBDa5yCm.js} +57 -23
  30. package/dist/inspector-BBDa5yCm.js.map +1 -0
  31. package/dist/{inspector-jY9O18z9.cjs → inspector-DAA1Wiyh.cjs} +58 -24
  32. package/dist/inspector-DAA1Wiyh.cjs.map +1 -0
  33. package/dist/lib/discovery-cli.cjs +1 -1
  34. package/dist/mcp/index.cjs +22 -25
  35. package/dist/mcp/index.cjs.map +1 -1
  36. package/dist/mcp/index.js +19 -22
  37. package/dist/mcp/index.js.map +1 -1
  38. package/dist/{use-app-Bfargfa3.js → use-app-Cr0auUa1.js} +2 -2
  39. package/dist/{use-app-Bfargfa3.js.map → use-app-Cr0auUa1.js.map} +1 -1
  40. package/dist/{use-app-CbsBEmwv.cjs → use-app-DPkj5Jp_.cjs} +2 -2
  41. package/dist/{use-app-CbsBEmwv.cjs.map → use-app-DPkj5Jp_.cjs.map} +1 -1
  42. package/package.json +17 -11
  43. package/template/dist/albums/albums.html +4 -4
  44. package/template/dist/albums/albums.json +1 -1
  45. package/template/dist/carousel/carousel.html +4 -4
  46. package/template/dist/carousel/carousel.json +1 -1
  47. package/template/dist/map/map.html +6 -6
  48. package/template/dist/map/map.json +1 -1
  49. package/template/dist/review/review.html +4 -4
  50. package/template/dist/review/review.json +1 -1
  51. package/template/node_modules/.bin/vite +2 -2
  52. package/template/node_modules/.bin/vitest +2 -2
  53. package/template/node_modules/.vite/deps/_metadata.json +4 -4
  54. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js +1 -1
  55. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps.js.map +1 -1
  56. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js +1 -1
  57. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_app-bridge.js.map +1 -1
  58. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js +1 -1
  59. package/template/node_modules/.vite-mcp/deps/@modelcontextprotocol_ext-apps_react.js.map +1 -1
  60. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js +4 -4
  61. package/template/node_modules/.vite-mcp/deps/@testing-library_react.js.map +1 -1
  62. package/template/node_modules/.vite-mcp/deps/_metadata.json +33 -33
  63. package/template/node_modules/.vite-mcp/deps/{client-CU1wWud4.js → client-B_5CX--u.js} +7 -7
  64. package/template/node_modules/.vite-mcp/deps/{client-CU1wWud4.js.map → client-B_5CX--u.js.map} +1 -1
  65. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js +1 -1
  66. package/template/node_modules/.vite-mcp/deps/embla-carousel-react.js.map +1 -1
  67. package/template/node_modules/.vite-mcp/deps/react-dom.js +3 -3
  68. package/template/node_modules/.vite-mcp/deps/react-dom.js.map +1 -1
  69. package/template/node_modules/.vite-mcp/deps/react-dom_client.js +1 -1
  70. package/template/node_modules/.vite-mcp/deps/react.js +3 -3
  71. package/template/node_modules/.vite-mcp/deps/react.js.map +1 -1
  72. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js +2 -2
  73. package/template/node_modules/.vite-mcp/deps/react_jsx-dev-runtime.js.map +1 -1
  74. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js +2 -2
  75. package/template/node_modules/.vite-mcp/deps/react_jsx-runtime.js.map +1 -1
  76. package/template/node_modules/.vite-mcp/deps/vitest.js +1024 -622
  77. package/template/node_modules/.vite-mcp/deps/vitest.js.map +1 -1
  78. package/template/package.json +6 -6
  79. package/template/tests/e2e/albums.spec.ts +24 -52
  80. package/template/tests/e2e/carousel.spec.ts +36 -58
  81. package/template/tests/e2e/map.spec.ts +35 -56
  82. package/template/tests/e2e/review.spec.ts +56 -85
  83. package/template/tests/e2e/visual.spec.ts +14 -12
  84. package/dist/inspector-D5DckQuU.js.map +0 -1
  85. package/dist/inspector-jY9O18z9.cjs.map +0 -1
@@ -82,7 +82,7 @@ function C({ force: e } = {}) {
82
82
  }
83
83
  var y = C();
84
84
  //#endregion
85
- //#region ../../../node_modules/.pnpm/@vitest+pretty-format@4.1.2/node_modules/@vitest/pretty-format/dist/index.js
85
+ //#region ../../../node_modules/.pnpm/@vitest+pretty-format@4.1.4/node_modules/@vitest/pretty-format/dist/index.js
86
86
  function _mergeNamespaces(n, m) {
87
87
  m.forEach(function(e) {
88
88
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -965,7 +965,7 @@ var plugins = {
965
965
  Error: ErrorPlugin
966
966
  };
967
967
  //#endregion
968
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/display.js
968
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/display.js
969
969
  var ansiColors$1 = {
970
970
  bold: ["1", "22"],
971
971
  dim: ["2", "22"],
@@ -1519,7 +1519,7 @@ function objDisplay$1(obj, options = {}) {
1519
1519
  return str;
1520
1520
  }
1521
1521
  //#endregion
1522
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/helpers.js
1522
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/helpers.js
1523
1523
  /**
1524
1524
  * Get original stacktrace without source map support the most performant way.
1525
1525
  * - Create only 1 stack frame.
@@ -2995,7 +2995,7 @@ function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
2995
2995
  return diffs.reduce((reduced, diff) => reduced + (diff[0] === 0 ? diff[1] : diff[0] === op ? hasCommonDiff ? y.inverse(diff[1]) : diff[1] : ""), "");
2996
2996
  }
2997
2997
  //#endregion
2998
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/serialize.js
2998
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/serialize.js
2999
2999
  var IS_RECORD_SYMBOL$1 = "@@__IMMUTABLE_RECORD__@@";
3000
3000
  var IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
3001
3001
  function isImmutable(v) {
@@ -3069,7 +3069,7 @@ function normalizeErrorMessage(message) {
3069
3069
  return message.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/getByTestId('__vitest_\d+__')/g, "page");
3070
3070
  }
3071
3071
  //#endregion
3072
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/error.js
3072
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/error.js
3073
3073
  function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
3074
3074
  if (!_err || typeof _err !== "object") return { message: String(_err) };
3075
3075
  const err = _err;
@@ -3092,7 +3092,7 @@ function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
3092
3092
  }
3093
3093
  }
3094
3094
  //#endregion
3095
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/timers.js
3095
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/timers.js
3096
3096
  var SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS");
3097
3097
  function getSafeTimers() {
3098
3098
  const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
@@ -3126,7 +3126,7 @@ function delay(timeout, scheduler = setTimeout) {
3126
3126
  return new Promise((resolve) => scheduler(resolve, timeout));
3127
3127
  }
3128
3128
  //#endregion
3129
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
3129
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
3130
3130
  var _DRIVE_LETTER_START_RE$2 = /^[A-Za-z]:\//;
3131
3131
  function normalizeWindowsPath$2(input = "") {
3132
3132
  if (!input) return input;
@@ -3205,7 +3205,7 @@ var isAbsolute$2 = function(p) {
3205
3205
  return _IS_ABSOLUTE_RE$2.test(p);
3206
3206
  };
3207
3207
  //#endregion
3208
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/source-map.js
3208
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/source-map.js
3209
3209
  var comma$1 = ",".charCodeAt(0);
3210
3210
  var chars$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
3211
3211
  var intToChar$1 = new Uint8Array(64);
@@ -3497,7 +3497,7 @@ function parseSingleV8Stack(raw) {
3497
3497
  function parseStacktrace(stack, options = {}) {
3498
3498
  const { ignoreStackEntries = stackIgnorePatterns } = options;
3499
3499
  let stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
3500
- const helperIndex = stacks.findLastIndex((s) => s.method === "__VITEST_HELPER__" || s.method === "async*__VITEST_HELPER__");
3500
+ const helperIndex = stacks.findLastIndex((s) => s.method === "__VITEST_HELPER__" || s.method === "async*__VITEST_HELPER__" || s.method === "async __VITEST_HELPER__");
3501
3501
  if (helperIndex >= 0) stacks = stacks.slice(helperIndex + 1);
3502
3502
  return stacks.map((stack) => {
3503
3503
  if (options.getUrlId) stack.file = options.getUrlId(stack.file);
@@ -3679,7 +3679,7 @@ var dirname$1 = function(p) {
3679
3679
  };
3680
3680
  globalThis.process?.platform;
3681
3681
  //#endregion
3682
- //#region ../../../node_modules/.pnpm/@vitest+runner@4.1.2/node_modules/@vitest/runner/dist/chunk-artifact.js
3682
+ //#region ../../../node_modules/.pnpm/@vitest+runner@4.1.4/node_modules/@vitest/runner/dist/chunk-artifact.js
3683
3683
  var PendingError = class extends Error {
3684
3684
  code = "VITEST_PENDING";
3685
3685
  taskId;
@@ -3877,7 +3877,7 @@ function withFixtures(fn, options) {
3877
3877
  if (!registrations.size) return fn(context);
3878
3878
  const usedFixtures = [];
3879
3879
  const usedProps = getUsedProps(fn);
3880
- for (const fixture of registrations.values()) if (fixture.auto || usedProps.has(fixture.name)) usedFixtures.push(fixture);
3880
+ for (const fixture of registrations.values()) if (isAutoFixture(fixture, options) || usedProps.has(fixture.name)) usedFixtures.push(fixture);
3881
3881
  if (!usedFixtures.length) return fn(context);
3882
3882
  if (!cleanupFnArrayMap.has(context)) cleanupFnArrayMap.set(context, []);
3883
3883
  const cleanupFnArray = cleanupFnArrayMap.get(context);
@@ -3913,6 +3913,11 @@ function withFixtures(fn, options) {
3913
3913
  return fn(context);
3914
3914
  };
3915
3915
  }
3916
+ function isAutoFixture(fixture, options) {
3917
+ if (!fixture.auto) return false;
3918
+ if (options?.suiteHook && fixture.scope === "test") return false;
3919
+ return true;
3920
+ }
3916
3921
  function isFixtureFunction(value) {
3917
3922
  return typeof value === "function";
3918
3923
  }
@@ -5494,10 +5499,12 @@ function recordAsyncOperation(test, promise) {
5494
5499
  function manageArtifactAttachment(attachment) {
5495
5500
  if (attachment.body == null && !attachment.path) throw new TypeError(`Test attachment requires "body" or "path" to be set. Both are missing.`);
5496
5501
  if (attachment.body && attachment.path) throw new TypeError(`Test attachment requires only one of "body" or "path" to be set. Both are specified.`);
5502
+ if (attachment.path && attachment.bodyEncoding) throw new TypeError(`Test attachment with "path" should not have "bodyEncoding" specified.`);
5497
5503
  if (attachment.body instanceof Uint8Array) attachment.body = encodeUint8Array(attachment.body);
5504
+ if (attachment.body != null) attachment.bodyEncoding ??= "base64";
5498
5505
  }
5499
5506
  //#endregion
5500
- //#region ../../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js
5507
+ //#region ../../../node_modules/.pnpm/vitest@4.1.4_@opentelemetry+api@1.9.0_@types+node@25.6.0_happy-dom@20.8.9_jsdom@29.0.1__4c3ad3159a5d6ab290fe85c67b420ce9/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js
5501
5508
  var NAME_WORKER_STATE = "__vitest_worker__";
5502
5509
  function getWorkerState() {
5503
5510
  const workerState = globalThis[NAME_WORKER_STATE];
@@ -5537,7 +5544,7 @@ async function waitForImportsToResolve() {
5537
5544
  await waitForImportsToResolve();
5538
5545
  }
5539
5546
  //#endregion
5540
- //#region ../../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js
5547
+ //#region ../../../node_modules/.pnpm/vitest@4.1.4_@opentelemetry+api@1.9.0_@types+node@25.6.0_happy-dom@20.8.9_jsdom@29.0.1__4c3ad3159a5d6ab290fe85c67b420ce9/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js
5541
5548
  var benchFns = /* @__PURE__ */ new WeakMap();
5542
5549
  var benchOptsMap = /* @__PURE__ */ new WeakMap();
5543
5550
  function getBenchOptions(key) {
@@ -5570,7 +5577,7 @@ function formatName(name) {
5570
5577
  return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
5571
5578
  }
5572
5579
  //#endregion
5573
- //#region ../../../node_modules/.pnpm/@vitest+spy@4.1.2/node_modules/@vitest/spy/dist/index.js
5580
+ //#region ../../../node_modules/.pnpm/@vitest+spy@4.1.4/node_modules/@vitest/spy/dist/index.js
5574
5581
  function isMockFunction(fn) {
5575
5582
  return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
5576
5583
  }
@@ -8835,7 +8842,7 @@ function use(fn) {
8835
8842
  }
8836
8843
  __name(use, "use");
8837
8844
  //#endregion
8838
- //#region ../../../node_modules/.pnpm/@vitest+expect@4.1.2/node_modules/@vitest/expect/dist/index.js
8845
+ //#region ../../../node_modules/.pnpm/@vitest+expect@4.1.4/node_modules/@vitest/expect/dist/index.js
8839
8846
  var ChaiStyleAssertions = (chai, utils) => {
8840
8847
  function defProperty(name, delegateTo) {
8841
8848
  utils.addProperty(chai.Assertion.prototype, name, function() {
@@ -9629,6 +9636,7 @@ function handleTestError(test, err) {
9629
9636
  test.result.errors ||= [];
9630
9637
  test.result.errors.push(processError(err));
9631
9638
  }
9639
+ /** wrap assertion function to support `expect.soft` and provide assertion name as `_name` */
9632
9640
  function wrapAssertion(utils, name, fn) {
9633
9641
  return function(...args) {
9634
9642
  if (name !== "withTest") utils.flag(this, "_name", name);
@@ -10196,54 +10204,60 @@ function getMatcherState(assertion, expect) {
10196
10204
  let task = utils_exports.flag(assertion, "vitest-test");
10197
10205
  const currentTestName = task?.fullTestName ?? "";
10198
10206
  if (task?.type !== "test") task = void 0;
10207
+ const matcherState = {
10208
+ ...getState(expect),
10209
+ currentTestName,
10210
+ customTesters: getCustomEqualityTesters(),
10211
+ isNot,
10212
+ utils: jestUtils,
10213
+ promise,
10214
+ equals,
10215
+ suppressedErrors: [],
10216
+ soft: utils_exports.flag(assertion, "soft"),
10217
+ poll: utils_exports.flag(assertion, "poll"),
10218
+ assertion
10219
+ };
10220
+ Object.assign(matcherState, { task });
10199
10221
  return {
10200
- state: {
10201
- ...getState(expect),
10202
- task,
10203
- currentTestName,
10204
- customTesters: getCustomEqualityTesters(),
10205
- isNot,
10206
- utils: jestUtils,
10207
- promise,
10208
- equals,
10209
- suppressedErrors: [],
10210
- soft: utils_exports.flag(assertion, "soft"),
10211
- poll: utils_exports.flag(assertion, "poll")
10212
- },
10222
+ state: matcherState,
10213
10223
  isNot,
10214
10224
  obj,
10215
10225
  customMessage
10216
10226
  };
10217
10227
  }
10218
10228
  var JestExtendError = class extends Error {
10219
- constructor(message, actual, expected, context) {
10229
+ constructor(message, actual, expected, __vitest_error_context__) {
10220
10230
  super(message);
10221
10231
  this.actual = actual;
10222
10232
  this.expected = expected;
10223
- this.context = context;
10233
+ this.__vitest_error_context__ = __vitest_error_context__;
10224
10234
  }
10225
10235
  };
10226
10236
  function JestExtendPlugin(c, expect, matchers) {
10227
10237
  return (_, utils) => {
10228
10238
  Object.entries(matchers).forEach(([expectAssertionName, expectAssertion]) => {
10229
- function expectWrapper(...args) {
10239
+ function __VITEST_EXTEND_ASSERTION__(...args) {
10230
10240
  const { state, isNot, obj, customMessage } = getMatcherState(this, expect);
10231
10241
  const result = expectAssertion.call(state, obj, ...args);
10232
10242
  if (result && typeof result === "object" && typeof result.then === "function") return result.then(({ pass, message, actual, expected, meta }) => {
10233
- if (pass && isNot || !pass && !isNot) throw new JestExtendError(customMessage != null ? customMessage : message(), actual, expected, {
10243
+ if (pass && isNot || !pass && !isNot) throw new JestExtendError((customMessage ? `${customMessage}: ` : "") + message(), actual, expected, {
10234
10244
  assertionName: expectAssertionName,
10235
10245
  meta
10236
10246
  });
10237
10247
  });
10238
10248
  const { pass, message, actual, expected, meta } = result;
10239
- if (pass && isNot || !pass && !isNot) throw new JestExtendError(customMessage != null ? customMessage : message(), actual, expected, {
10249
+ if (pass && isNot || !pass && !isNot) throw new JestExtendError((customMessage ? `${customMessage}: ` : "") + message(), actual, expected, {
10240
10250
  assertionName: expectAssertionName,
10241
10251
  meta
10242
10252
  });
10243
10253
  }
10244
- const softWrapper = wrapAssertion(utils, expectAssertionName, expectWrapper);
10254
+ const softWrapper = wrapAssertion(utils, expectAssertionName, __VITEST_EXTEND_ASSERTION__);
10245
10255
  utils.addMethod(globalThis[JEST_MATCHERS_OBJECT].matchers, expectAssertionName, softWrapper);
10246
10256
  utils.addMethod(c.Assertion.prototype, expectAssertionName, softWrapper);
10257
+ if (expectAssertion.__vitest_poll_takeover__) {
10258
+ const addedMethod = c.Assertion.prototype[expectAssertionName];
10259
+ Object.defineProperty(addedMethod, "__vitest_poll_takeover__", { value: true });
10260
+ }
10247
10261
  class CustomMatcher extends AsymmetricMatcher$1 {
10248
10262
  constructor(inverse = false, ...sample) {
10249
10263
  super(sample, inverse);
@@ -10290,7 +10304,7 @@ var JestExtend = (chai, utils) => {
10290
10304
  });
10291
10305
  };
10292
10306
  //#endregion
10293
- //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/offset.js
10307
+ //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.4/node_modules/@vitest/utils/dist/offset.js
10294
10308
  var lineSplitRE = /\r?\n/;
10295
10309
  function positionToOffset(source, lineNumber, columnNumber) {
10296
10310
  const lines = source.split(lineSplitRE);
@@ -10314,113 +10328,63 @@ function offsetToLineNumber(source, offset) {
10314
10328
  return line + 1;
10315
10329
  }
10316
10330
  //#endregion
10317
- //#region ../../../node_modules/.pnpm/@vitest+snapshot@4.1.2/node_modules/@vitest/snapshot/dist/index.js
10318
- async function saveInlineSnapshots(environment, snapshots) {
10319
- const MagicString = (await import("./magic-string.es-Cklsmr-5.js")).default;
10320
- const files = new Set(snapshots.map((i) => i.file));
10321
- await Promise.all(Array.from(files).map(async (file) => {
10322
- const snaps = snapshots.filter((i) => i.file === file);
10323
- const code = await environment.readSnapshotFile(file);
10324
- if (code == null) throw new Error(`cannot read ${file} when saving inline snapshot`);
10325
- const s = new MagicString(code);
10326
- for (const snap of snaps) replaceInlineSnap(code, s, positionToOffset(code, snap.line, snap.column), snap.snapshot);
10327
- const transformed = s.toString();
10328
- if (transformed !== code) await environment.saveSnapshotFile(file, transformed);
10329
- }));
10330
- }
10331
- var startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*\{/;
10332
- function replaceObjectSnap(code, s, index, newSnap) {
10333
- let _code = code.slice(index);
10334
- const startMatch = startObjectRegex.exec(_code);
10335
- if (!startMatch) return false;
10336
- _code = _code.slice(startMatch.index);
10337
- let callEnd = getCallLastIndex(_code);
10338
- if (callEnd === null) return false;
10339
- callEnd += index + startMatch.index;
10340
- const shapeEnd = getObjectShapeEndIndex(code, index + startMatch.index + startMatch[0].length);
10341
- const snap = `, ${prepareSnapString(newSnap, code, index)}`;
10342
- if (shapeEnd === callEnd) s.appendLeft(callEnd, snap);
10343
- else s.overwrite(shapeEnd, callEnd, snap);
10344
- return true;
10345
- }
10346
- function getObjectShapeEndIndex(code, index) {
10347
- let startBraces = 1;
10348
- let endBraces = 0;
10349
- while (startBraces !== endBraces && index < code.length) {
10350
- const s = code[index++];
10351
- if (s === "{") startBraces++;
10352
- else if (s === "}") endBraces++;
10353
- }
10354
- return index;
10355
- }
10356
- function prepareSnapString(snap, source, index) {
10357
- const lineNumber = offsetToLineNumber(source, index);
10358
- const indent = source.split(lineSplitRE)[lineNumber - 1].match(/^\s*/)[0] || "";
10359
- const indentNext = indent.includes(" ") ? `${indent}\t` : `${indent} `;
10360
- const lines = snap.trim().replace(/\\/g, "\\\\").split(/\n/g);
10361
- const isOneline = lines.length <= 1;
10362
- const quote = "`";
10363
- if (isOneline) return `${quote}${lines.join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}${quote}`;
10364
- return `${quote}\n${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}\n${indent}${quote}`;
10365
- }
10366
- var toMatchInlineName = "toMatchInlineSnapshot";
10367
- var toThrowErrorMatchingInlineName = "toThrowErrorMatchingInlineSnapshot";
10368
- function getCodeStartingAtIndex(code, index) {
10369
- const indexInline = index - 21;
10370
- if (code.slice(indexInline, index) === toMatchInlineName) return {
10371
- code: code.slice(indexInline),
10372
- index: indexInline
10373
- };
10374
- const indexThrowInline = index - 34;
10375
- if (code.slice(index - indexThrowInline, index) === toThrowErrorMatchingInlineName) return {
10376
- code: code.slice(index - indexThrowInline),
10377
- index: index - indexThrowInline
10378
- };
10379
- return {
10380
- code: code.slice(index),
10381
- index
10382
- };
10383
- }
10384
- var startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*[\w$]*(['"`)])/;
10385
- function replaceInlineSnap(code, s, currentIndex, newSnap) {
10386
- const { code: codeStartingAtIndex, index } = getCodeStartingAtIndex(code, currentIndex);
10387
- const startMatch = startRegex.exec(codeStartingAtIndex);
10388
- const firstKeywordMatch = /toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/.exec(codeStartingAtIndex);
10389
- if (!startMatch || startMatch.index !== firstKeywordMatch?.index) return replaceObjectSnap(code, s, index, newSnap);
10390
- const quote = startMatch[1];
10391
- const startIndex = index + startMatch.index + startMatch[0].length;
10392
- const snapString = prepareSnapString(newSnap, code, index);
10393
- if (quote === ")") {
10394
- s.appendRight(startIndex - 1, snapString);
10395
- return true;
10331
+ //#region ../../../node_modules/.pnpm/vitest@4.1.4_@opentelemetry+api@1.9.0_@types+node@25.6.0_happy-dom@20.8.9_jsdom@29.0.1__4c3ad3159a5d6ab290fe85c67b420ce9/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
10332
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
10333
+ //#endregion
10334
+ //#region ../../../node_modules/.pnpm/vitest@4.1.4_@opentelemetry+api@1.9.0_@types+node@25.6.0_happy-dom@20.8.9_jsdom@29.0.1__4c3ad3159a5d6ab290fe85c67b420ce9/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js
10335
+ var RealDate = Date;
10336
+ var now = null;
10337
+ var MockDate = class MockDate extends RealDate {
10338
+ constructor(y, m, d, h, M, s, ms) {
10339
+ super();
10340
+ let date;
10341
+ switch (arguments.length) {
10342
+ case 0:
10343
+ if (now !== null) date = new RealDate(now.valueOf());
10344
+ else date = new RealDate();
10345
+ break;
10346
+ case 1:
10347
+ date = new RealDate(y);
10348
+ break;
10349
+ default:
10350
+ d = typeof d === "undefined" ? 1 : d;
10351
+ h = h || 0;
10352
+ M = M || 0;
10353
+ s = s || 0;
10354
+ ms = ms || 0;
10355
+ date = new RealDate(y, m, d, h, M, s, ms);
10356
+ break;
10357
+ }
10358
+ Object.setPrototypeOf(date, MockDate.prototype);
10359
+ return date;
10396
10360
  }
10397
- const endMatch = new RegExp(`(?:^|[^\\\\])${quote}`).exec(code.slice(startIndex));
10398
- if (!endMatch) return false;
10399
- const endIndex = startIndex + endMatch.index + endMatch[0].length;
10400
- s.overwrite(startIndex - 1, endIndex, snapString);
10401
- return true;
10361
+ };
10362
+ MockDate.UTC = RealDate.UTC;
10363
+ MockDate.now = function() {
10364
+ return new MockDate().valueOf();
10365
+ };
10366
+ MockDate.parse = function(dateString) {
10367
+ return RealDate.parse(dateString);
10368
+ };
10369
+ MockDate.toString = function() {
10370
+ return RealDate.toString();
10371
+ };
10372
+ function mockDate(date) {
10373
+ const dateObj = new RealDate(date.valueOf());
10374
+ if (Number.isNaN(dateObj.getTime())) throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
10375
+ globalThis.Date = MockDate;
10376
+ now = dateObj.valueOf();
10402
10377
  }
10403
- var INDENTATION_REGEX = /^([^\S\n]*)\S/m;
10404
- function stripSnapshotIndentation(inlineSnapshot) {
10405
- const match = inlineSnapshot.match(INDENTATION_REGEX);
10406
- if (!match || !match[1]) return inlineSnapshot;
10407
- const indentation = match[1];
10408
- const lines = inlineSnapshot.split(/\n/g);
10409
- if (lines.length <= 2) return inlineSnapshot;
10410
- if (lines[0].trim() !== "" || lines.at(-1)?.trim() !== "") return inlineSnapshot;
10411
- for (let i = 1; i < lines.length - 1; i++) if (lines[i] !== "") {
10412
- if (lines[i].indexOf(indentation) !== 0) return inlineSnapshot;
10413
- lines[i] = lines[i].substring(indentation.length);
10414
- }
10415
- lines[lines.length - 1] = "";
10416
- inlineSnapshot = lines.join("\n");
10417
- return inlineSnapshot;
10378
+ function resetDate() {
10379
+ globalThis.Date = RealDate;
10418
10380
  }
10419
- async function saveRawSnapshots(environment, snapshots) {
10420
- await Promise.all(snapshots.map(async (snap) => {
10421
- if (!snap.readonly) await environment.saveSnapshotFile(snap.file, snap.snapshot);
10422
- }));
10381
+ var { get } = Reflect;
10382
+ function rpc() {
10383
+ const { rpc } = getWorkerState();
10384
+ return rpc;
10423
10385
  }
10386
+ //#endregion
10387
+ //#region ../../../node_modules/.pnpm/@vitest+snapshot@4.1.4/node_modules/@vitest/snapshot/dist/index.js
10424
10388
  function getDefaultExportFromCjs(x) {
10425
10389
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
10426
10390
  }
@@ -10616,6 +10580,127 @@ var CounterMap = class extends DefaultMap {
10616
10580
  return total;
10617
10581
  }
10618
10582
  };
10583
+ /* @__NO_SIDE_EFFECTS__ */
10584
+ function memo(fn) {
10585
+ const cache = /* @__PURE__ */ new Map();
10586
+ return (arg) => {
10587
+ if (!cache.has(arg)) cache.set(arg, fn(arg));
10588
+ return cache.get(arg);
10589
+ };
10590
+ }
10591
+ async function saveInlineSnapshots(environment, snapshots) {
10592
+ const MagicString = (await import("./magic-string.es-Cklsmr-5.js")).default;
10593
+ const files = new Set(snapshots.map((i) => i.file));
10594
+ await Promise.all(Array.from(files).map(async (file) => {
10595
+ const snaps = snapshots.filter((i) => i.file === file);
10596
+ const code = await environment.readSnapshotFile(file);
10597
+ if (code == null) throw new Error(`cannot read ${file} when saving inline snapshot`);
10598
+ const s = new MagicString(code);
10599
+ for (const snap of snaps) replaceInlineSnap(code, s, positionToOffset(code, snap.line, snap.column), snap.snapshot, snap.assertionName);
10600
+ const transformed = s.toString();
10601
+ if (transformed !== code) await environment.saveSnapshotFile(file, transformed);
10602
+ }));
10603
+ }
10604
+ var defaultStartObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*\{/;
10605
+ function escapeRegExp(s) {
10606
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
10607
+ }
10608
+ var buildStartObjectRegex = /* @__PURE__ */ memo((assertionName) => {
10609
+ const replaced = defaultStartObjectRegex.source.replace("toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot", escapeRegExp(assertionName));
10610
+ return new RegExp(replaced);
10611
+ });
10612
+ function replaceObjectSnap(code, s, index, newSnap, assertionName) {
10613
+ let _code = code.slice(index);
10614
+ const startMatch = (assertionName ? buildStartObjectRegex(assertionName) : defaultStartObjectRegex).exec(_code);
10615
+ if (!startMatch) return false;
10616
+ _code = _code.slice(startMatch.index);
10617
+ let callEnd = getCallLastIndex(_code);
10618
+ if (callEnd === null) return false;
10619
+ callEnd += index + startMatch.index;
10620
+ const shapeEnd = getObjectShapeEndIndex(code, index + startMatch.index + startMatch[0].length);
10621
+ const snap = `, ${prepareSnapString(newSnap, code, index)}`;
10622
+ if (shapeEnd === callEnd) s.appendLeft(callEnd, snap);
10623
+ else s.overwrite(shapeEnd, callEnd, snap);
10624
+ return true;
10625
+ }
10626
+ function getObjectShapeEndIndex(code, index) {
10627
+ let startBraces = 1;
10628
+ let endBraces = 0;
10629
+ while (startBraces !== endBraces && index < code.length) {
10630
+ const s = code[index++];
10631
+ if (s === "{") startBraces++;
10632
+ else if (s === "}") endBraces++;
10633
+ }
10634
+ return index;
10635
+ }
10636
+ function prepareSnapString(snap, source, index) {
10637
+ const lineNumber = offsetToLineNumber(source, index);
10638
+ const indent = source.split(lineSplitRE)[lineNumber - 1].match(/^\s*/)[0] || "";
10639
+ const indentNext = indent.includes(" ") ? `${indent}\t` : `${indent} `;
10640
+ const lines = snap.trim().replace(/\\/g, "\\\\").split(/\n/g);
10641
+ const isOneline = lines.length <= 1;
10642
+ const quote = "`";
10643
+ if (isOneline) return `${quote}${lines.join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}${quote}`;
10644
+ return `${quote}\n${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}\n${indent}${quote}`;
10645
+ }
10646
+ var defaultMethodNames = ["toMatchInlineSnapshot", "toThrowErrorMatchingInlineSnapshot"];
10647
+ function getCodeStartingAtIndex(code, index, methodNames) {
10648
+ for (const name of methodNames) {
10649
+ const adjusted = index - name.length;
10650
+ if (adjusted >= 0 && code.slice(adjusted, index) === name) return {
10651
+ code: code.slice(adjusted),
10652
+ index: adjusted
10653
+ };
10654
+ }
10655
+ return {
10656
+ code: code.slice(index),
10657
+ index
10658
+ };
10659
+ }
10660
+ var defaultStartRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*[\w$]*(['"`)])/;
10661
+ var buildStartRegex = /* @__PURE__ */ memo((assertionName) => {
10662
+ const replaced = defaultStartRegex.source.replace("toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot", escapeRegExp(assertionName));
10663
+ return new RegExp(replaced);
10664
+ });
10665
+ function replaceInlineSnap(code, s, currentIndex, newSnap, assertionName) {
10666
+ const { code: codeStartingAtIndex, index } = getCodeStartingAtIndex(code, currentIndex, assertionName ? [assertionName] : defaultMethodNames);
10667
+ const startMatch = (assertionName ? buildStartRegex(assertionName) : defaultStartRegex).exec(codeStartingAtIndex);
10668
+ const firstKeywordMatch = (assertionName ? new RegExp(escapeRegExp(assertionName)) : /toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/).exec(codeStartingAtIndex);
10669
+ if (!startMatch || startMatch.index !== firstKeywordMatch?.index) return replaceObjectSnap(code, s, index, newSnap, assertionName);
10670
+ const quote = startMatch[1];
10671
+ const startIndex = index + startMatch.index + startMatch[0].length;
10672
+ const snapString = prepareSnapString(newSnap, code, index);
10673
+ if (quote === ")") {
10674
+ s.appendRight(startIndex - 1, snapString);
10675
+ return true;
10676
+ }
10677
+ const endMatch = new RegExp(`(?:^|[^\\\\])${quote}`).exec(code.slice(startIndex));
10678
+ if (!endMatch) return false;
10679
+ const endIndex = startIndex + endMatch.index + endMatch[0].length;
10680
+ s.overwrite(startIndex - 1, endIndex, snapString);
10681
+ return true;
10682
+ }
10683
+ var INDENTATION_REGEX = /^([^\S\n]*)\S/m;
10684
+ function stripSnapshotIndentation(inlineSnapshot) {
10685
+ const match = inlineSnapshot.match(INDENTATION_REGEX);
10686
+ if (!match || !match[1]) return inlineSnapshot;
10687
+ const indentation = match[1];
10688
+ const lines = inlineSnapshot.split(/\n/g);
10689
+ if (lines.length <= 2) return inlineSnapshot;
10690
+ if (lines[0].trim() !== "" || lines.at(-1)?.trim() !== "") return inlineSnapshot;
10691
+ for (let i = 1; i < lines.length - 1; i++) if (lines[i] !== "") {
10692
+ if (lines[i].indexOf(indentation) !== 0) return inlineSnapshot;
10693
+ lines[i] = lines[i].substring(indentation.length);
10694
+ }
10695
+ lines[lines.length - 1] = "";
10696
+ inlineSnapshot = lines.join("\n");
10697
+ return inlineSnapshot;
10698
+ }
10699
+ async function saveRawSnapshots(environment, snapshots) {
10700
+ await Promise.all(snapshots.map(async (snap) => {
10701
+ if (!snap.readonly) await environment.saveSnapshotFile(snap.file, snap.snapshot);
10702
+ }));
10703
+ }
10619
10704
  function isSameStackPosition(x, y) {
10620
10705
  return x.file === y.file && x.column === y.column && x.line === y.line;
10621
10706
  }
@@ -10687,6 +10772,9 @@ var SnapshotState = class SnapshotState {
10687
10772
  const snapshotPath = await options.snapshotEnvironment.resolvePath(testFilePath);
10688
10773
  return new SnapshotState(testFilePath, snapshotPath, await options.snapshotEnvironment.readSnapshotFile(snapshotPath), options);
10689
10774
  }
10775
+ get snapshotUpdateState() {
10776
+ return this._updateSnapshot;
10777
+ }
10690
10778
  get environment() {
10691
10779
  return this._environment;
10692
10780
  }
@@ -10715,19 +10803,24 @@ var SnapshotState = class SnapshotState {
10715
10803
  _inferInlineSnapshotStack(stacks) {
10716
10804
  const promiseIndex = stacks.findIndex((i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/));
10717
10805
  if (promiseIndex !== -1) return stacks[promiseIndex + 3];
10806
+ const pollChainIndex = stacks.findIndex((i) => i.method.match(/__VITEST_POLL_CHAIN__/));
10807
+ if (pollChainIndex !== -1) return stacks[pollChainIndex + 1];
10718
10808
  for (let i = 0; i < stacks.length; i++) {
10719
10809
  const match = stacks[i].method.match(/__INLINE_SNAPSHOT_OFFSET_(\d+)__/);
10720
10810
  if (match) return stacks[i + Number(match[1])] ?? null;
10721
10811
  }
10812
+ const customMatcherIndex = stacks.findIndex((i) => i.method.includes("__VITEST_EXTEND_ASSERTION__"));
10813
+ if (customMatcherIndex !== -1) return stacks[customMatcherIndex + 3] ?? null;
10722
10814
  const stackIndex = stacks.findIndex((i) => i.method.includes("__INLINE_SNAPSHOT__"));
10723
10815
  return stackIndex !== -1 ? stacks[stackIndex + 2] : null;
10724
10816
  }
10725
10817
  _addSnapshot(key, receivedSerialized, options) {
10726
10818
  this._dirty = true;
10727
10819
  if (options.stack) this._inlineSnapshots.push({
10820
+ ...options.stack,
10728
10821
  snapshot: receivedSerialized,
10729
10822
  testId: options.testId,
10730
- ...options.stack
10823
+ assertionName: options.assertionName
10731
10824
  });
10732
10825
  else if (options.rawSnapshot) this._rawSnapshots.push({
10733
10826
  ...options.rawSnapshot,
@@ -10735,19 +10828,103 @@ var SnapshotState = class SnapshotState {
10735
10828
  });
10736
10829
  else this._snapshotData[key] = receivedSerialized;
10737
10830
  }
10738
- async save() {
10739
- const hasExternalSnapshots = Object.keys(this._snapshotData).length;
10740
- const hasInlineSnapshots = this._inlineSnapshots.length;
10741
- const hasRawSnapshots = this._rawSnapshots.length;
10742
- const isEmpty = !hasExternalSnapshots && !hasInlineSnapshots && !hasRawSnapshots;
10743
- const status = {
10744
- deleted: false,
10745
- saved: false
10831
+ _resolveKey(testId, testName, key) {
10832
+ this._counters.increment(testName);
10833
+ const count = this._counters.get(testName);
10834
+ if (!key) key = testNameToKey(testName, count);
10835
+ this._testIdToKeys.get(testId).push(key);
10836
+ return {
10837
+ key,
10838
+ count
10746
10839
  };
10747
- if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
10748
- if (hasExternalSnapshots) {
10749
- await saveSnapshotFile(this._environment, this._snapshotData, this.snapshotPath);
10750
- this._fileExists = true;
10840
+ }
10841
+ _resolveInlineStack(options) {
10842
+ const { testId, snapshot, assertionName, error } = options;
10843
+ const stacks = parseErrorStacktrace(error, { ignoreStackEntries: [] });
10844
+ const _stack = this._inferInlineSnapshotStack(stacks);
10845
+ if (!_stack) {
10846
+ const message = stacks.map((s) => ` ${s.file}:${s.line}:${s.column}${s.method ? ` (${s.method})` : ""}`).join("\n");
10847
+ throw new Error(`@vitest/snapshot: Couldn't infer stack frame for inline snapshot.\n${message}`);
10848
+ }
10849
+ const stack = this.environment.processStackTrace?.(_stack) || _stack;
10850
+ stack.column--;
10851
+ const snapshotsWithSameStack = this._inlineSnapshotStacks.filter((s) => isSameStackPosition(s, stack));
10852
+ if (snapshotsWithSameStack.length > 0) {
10853
+ this._inlineSnapshots = this._inlineSnapshots.filter((s) => !isSameStackPosition(s, stack));
10854
+ const differentSnapshot = snapshotsWithSameStack.find((s) => s.snapshot !== snapshot);
10855
+ if (differentSnapshot) throw Object.assign(/* @__PURE__ */ new Error(`${assertionName} with different snapshots cannot be called at the same location`), {
10856
+ actual: snapshot,
10857
+ expected: differentSnapshot.snapshot
10858
+ });
10859
+ }
10860
+ this._inlineSnapshotStacks.push({
10861
+ ...stack,
10862
+ testId,
10863
+ snapshot
10864
+ });
10865
+ return stack;
10866
+ }
10867
+ _reconcile(opts) {
10868
+ if (opts.hasSnapshot && this._updateSnapshot === "all" || (!opts.hasSnapshot || !opts.snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
10869
+ if (this._updateSnapshot === "all") if (!opts.pass) {
10870
+ if (opts.hasSnapshot) this.updated.increment(opts.testId);
10871
+ else this.added.increment(opts.testId);
10872
+ this._addSnapshot(opts.key, opts.addValue, {
10873
+ stack: opts.stack,
10874
+ testId: opts.testId,
10875
+ rawSnapshot: opts.rawSnapshot,
10876
+ assertionName: opts.assertionName
10877
+ });
10878
+ } else this.matched.increment(opts.testId);
10879
+ else {
10880
+ this._addSnapshot(opts.key, opts.addValue, {
10881
+ stack: opts.stack,
10882
+ testId: opts.testId,
10883
+ rawSnapshot: opts.rawSnapshot,
10884
+ assertionName: opts.assertionName
10885
+ });
10886
+ this.added.increment(opts.testId);
10887
+ }
10888
+ return {
10889
+ actual: "",
10890
+ count: opts.count,
10891
+ expected: "",
10892
+ key: opts.key,
10893
+ pass: true
10894
+ };
10895
+ } else if (!opts.pass) {
10896
+ this.unmatched.increment(opts.testId);
10897
+ return {
10898
+ actual: opts.actualDisplay,
10899
+ count: opts.count,
10900
+ expected: opts.expectedDisplay,
10901
+ key: opts.key,
10902
+ pass: false
10903
+ };
10904
+ } else {
10905
+ this.matched.increment(opts.testId);
10906
+ return {
10907
+ actual: "",
10908
+ count: opts.count,
10909
+ expected: "",
10910
+ key: opts.key,
10911
+ pass: true
10912
+ };
10913
+ }
10914
+ }
10915
+ async save() {
10916
+ const hasExternalSnapshots = Object.keys(this._snapshotData).length;
10917
+ const hasInlineSnapshots = this._inlineSnapshots.length;
10918
+ const hasRawSnapshots = this._rawSnapshots.length;
10919
+ const isEmpty = !hasExternalSnapshots && !hasInlineSnapshots && !hasRawSnapshots;
10920
+ const status = {
10921
+ deleted: false,
10922
+ saved: false
10923
+ };
10924
+ if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
10925
+ if (hasExternalSnapshots) {
10926
+ await saveSnapshotFile(this._environment, this._snapshotData, this.snapshotPath);
10927
+ this._fileExists = true;
10751
10928
  }
10752
10929
  if (hasInlineSnapshots) await saveInlineSnapshots(this._environment, this._inlineSnapshots);
10753
10930
  if (hasRawSnapshots) await saveRawSnapshots(this._environment, this._rawSnapshots);
@@ -10774,11 +10951,24 @@ var SnapshotState = class SnapshotState {
10774
10951
  this._uncheckedKeys.clear();
10775
10952
  }
10776
10953
  }
10777
- match({ testId, testName, received, key, inlineSnapshot, isInline, error, rawSnapshot }) {
10778
- this._counters.increment(testName);
10779
- const count = this._counters.get(testName);
10780
- if (!key) key = testNameToKey(testName, count);
10781
- this._testIdToKeys.get(testId).push(key);
10954
+ probeExpectedSnapshot(options) {
10955
+ const count = this._counters.get(options.testName) + 1;
10956
+ const key = testNameToKey(options.testName, count);
10957
+ return {
10958
+ key,
10959
+ count,
10960
+ data: options?.isInline ? options.inlineSnapshot : this._snapshotData[key],
10961
+ markAsChecked: () => {
10962
+ this._counters.increment(options.testName);
10963
+ this._testIdToKeys.get(options.testId).push(key);
10964
+ this._uncheckedKeys.delete(key);
10965
+ }
10966
+ };
10967
+ }
10968
+ match({ testId, testName, received, key, inlineSnapshot, isInline, error, rawSnapshot, assertionName }) {
10969
+ const resolved = this._resolveKey(testId, testName, key);
10970
+ key = resolved.key;
10971
+ const count = resolved.count;
10782
10972
  if (!(isInline && this._snapshotData[key] !== void 0)) this._uncheckedKeys.delete(key);
10783
10973
  let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, void 0, this._snapshotFormat);
10784
10974
  if (!rawSnapshot) receivedSerialized = addExtraLineBreaks(receivedSerialized);
@@ -10791,72 +10981,49 @@ var SnapshotState = class SnapshotState {
10791
10981
  const hasSnapshot = expected !== void 0;
10792
10982
  const snapshotIsPersisted = isInline || this._fileExists || rawSnapshot && rawSnapshot.content != null;
10793
10983
  if (pass && !isInline && !rawSnapshot) this._snapshotData[key] = receivedSerialized;
10794
- let stack;
10795
- if (isInline) {
10796
- const stacks = parseErrorStacktrace(error || /* @__PURE__ */ new Error("snapshot"), { ignoreStackEntries: [] });
10797
- const _stack = this._inferInlineSnapshotStack(stacks);
10798
- if (!_stack) throw new Error(`@vitest/snapshot: Couldn't infer stack frame for inline snapshot.\n${JSON.stringify(stacks)}`);
10799
- stack = this.environment.processStackTrace?.(_stack) || _stack;
10800
- stack.column--;
10801
- const snapshotsWithSameStack = this._inlineSnapshotStacks.filter((s) => isSameStackPosition(s, stack));
10802
- if (snapshotsWithSameStack.length > 0) {
10803
- this._inlineSnapshots = this._inlineSnapshots.filter((s) => !isSameStackPosition(s, stack));
10804
- const differentSnapshot = snapshotsWithSameStack.find((s) => s.snapshot !== receivedSerialized);
10805
- if (differentSnapshot) throw Object.assign(/* @__PURE__ */ new Error("toMatchInlineSnapshot with different snapshots cannot be called at the same location"), {
10806
- actual: receivedSerialized,
10807
- expected: differentSnapshot.snapshot
10808
- });
10809
- }
10810
- this._inlineSnapshotStacks.push({
10811
- ...stack,
10812
- testId,
10813
- snapshot: receivedSerialized
10814
- });
10815
- }
10816
- if (hasSnapshot && this._updateSnapshot === "all" || (!hasSnapshot || !snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
10817
- if (this._updateSnapshot === "all") if (!pass) {
10818
- if (hasSnapshot) this.updated.increment(testId);
10819
- else this.added.increment(testId);
10820
- this._addSnapshot(key, receivedSerialized, {
10821
- stack,
10822
- testId,
10823
- rawSnapshot
10824
- });
10825
- } else this.matched.increment(testId);
10826
- else {
10827
- this._addSnapshot(key, receivedSerialized, {
10828
- stack,
10829
- testId,
10830
- rawSnapshot
10831
- });
10832
- this.added.increment(testId);
10833
- }
10834
- return {
10835
- actual: "",
10836
- count,
10837
- expected: "",
10838
- key,
10839
- pass: true
10840
- };
10841
- } else if (!pass) {
10842
- this.unmatched.increment(testId);
10843
- return {
10844
- actual: rawSnapshot ? receivedSerialized : removeExtraLineBreaks(receivedSerialized),
10845
- count,
10846
- expected: expectedTrimmed !== void 0 ? rawSnapshot ? expectedTrimmed : removeExtraLineBreaks(expectedTrimmed) : void 0,
10847
- key,
10848
- pass: false
10849
- };
10850
- } else {
10851
- this.matched.increment(testId);
10852
- return {
10853
- actual: "",
10854
- count,
10855
- expected: "",
10856
- key,
10857
- pass: true
10858
- };
10859
- }
10984
+ const stack = isInline ? this._resolveInlineStack({
10985
+ testId,
10986
+ snapshot: receivedSerialized,
10987
+ assertionName: assertionName || "toMatchInlineSnapshot",
10988
+ error: error || /* @__PURE__ */ new Error("snapshot")
10989
+ }) : void 0;
10990
+ return this._reconcile({
10991
+ testId,
10992
+ key,
10993
+ count,
10994
+ pass,
10995
+ hasSnapshot,
10996
+ snapshotIsPersisted: !!snapshotIsPersisted,
10997
+ addValue: receivedSerialized,
10998
+ actualDisplay: rawSnapshot ? receivedSerialized : removeExtraLineBreaks(receivedSerialized),
10999
+ expectedDisplay: expectedTrimmed !== void 0 ? rawSnapshot ? expectedTrimmed : removeExtraLineBreaks(expectedTrimmed) : void 0,
11000
+ stack,
11001
+ rawSnapshot,
11002
+ assertionName
11003
+ });
11004
+ }
11005
+ processDomainSnapshot({ testId, received, expectedSnapshot, matchResult, isInline, error, assertionName }) {
11006
+ const stack = isInline ? this._resolveInlineStack({
11007
+ testId,
11008
+ snapshot: received,
11009
+ assertionName,
11010
+ error: error || /* @__PURE__ */ new Error("STACK_TRACE_ERROR")
11011
+ }) : void 0;
11012
+ const actualResolved = matchResult?.resolved ?? received;
11013
+ const expectedResolved = matchResult?.expected ?? expectedSnapshot.data;
11014
+ return this._reconcile({
11015
+ testId,
11016
+ key: expectedSnapshot.key,
11017
+ count: expectedSnapshot.count,
11018
+ pass: matchResult?.pass ?? false,
11019
+ hasSnapshot: !!expectedSnapshot.data,
11020
+ snapshotIsPersisted: isInline ? true : this._fileExists,
11021
+ addValue: actualResolved,
11022
+ actualDisplay: removeExtraLineBreaks(actualResolved),
11023
+ expectedDisplay: expectedResolved !== void 0 ? removeExtraLineBreaks(expectedResolved) : void 0,
11024
+ stack,
11025
+ assertionName
11026
+ });
10860
11027
  }
10861
11028
  async pack() {
10862
11029
  const snapshot = {
@@ -10925,22 +11092,41 @@ var SnapshotClient = class {
10925
11092
  if (!state) throw new Error(`The snapshot state for '${filepath}' is not found. Did you call 'SnapshotClient.setup()'?`);
10926
11093
  return state;
10927
11094
  }
10928
- assert(options) {
10929
- const { filepath, name, testId = name, message, isInline = false, properties, inlineSnapshot, error, errorMessage, rawSnapshot } = options;
11095
+ match(options) {
11096
+ const { filepath, name, testId = name, message, isInline = false, properties, inlineSnapshot, error, errorMessage, rawSnapshot, assertionName } = options;
10930
11097
  let { received } = options;
10931
11098
  if (!filepath) throw new Error("Snapshot cannot be used outside of test");
10932
11099
  const snapshotState = this.getSnapshotState(filepath);
11100
+ const testName = [name, ...message ? [message] : []].join(" > ");
11101
+ const expectedSnapshot = snapshotState.probeExpectedSnapshot({
11102
+ testName,
11103
+ testId,
11104
+ isInline,
11105
+ inlineSnapshot
11106
+ });
10933
11107
  if (typeof properties === "object") {
10934
- if (typeof received !== "object" || !received) throw new Error("Received value must be an object when the matcher has properties");
11108
+ if (typeof received !== "object" || !received) {
11109
+ expectedSnapshot.markAsChecked();
11110
+ throw new Error("Received value must be an object when the matcher has properties");
11111
+ }
11112
+ let propertiesPass;
10935
11113
  try {
10936
- if (!(this.options.isEqual?.(received, properties) ?? false)) throw createMismatchError("Snapshot properties mismatched", snapshotState.expand, received, properties);
10937
- else received = deepMergeSnapshot(received, properties);
11114
+ propertiesPass = this.options.isEqual?.(received, properties) ?? false;
10938
11115
  } catch (err) {
10939
- err.message = errorMessage || "Snapshot mismatched";
11116
+ expectedSnapshot.markAsChecked();
10940
11117
  throw err;
10941
11118
  }
11119
+ if (!propertiesPass) {
11120
+ expectedSnapshot.markAsChecked();
11121
+ return {
11122
+ pass: false,
11123
+ message: () => errorMessage || "Snapshot properties mismatched",
11124
+ actual: received,
11125
+ expected: properties
11126
+ };
11127
+ }
11128
+ received = deepMergeSnapshot(received, properties);
10942
11129
  }
10943
- const testName = [name, ...message ? [message] : []].join(" > ");
10944
11130
  const { actual, expected, key, pass } = snapshotState.match({
10945
11131
  testId,
10946
11132
  testName,
@@ -10948,9 +11134,97 @@ var SnapshotClient = class {
10948
11134
  isInline,
10949
11135
  error,
10950
11136
  inlineSnapshot,
10951
- rawSnapshot
11137
+ rawSnapshot,
11138
+ assertionName
11139
+ });
11140
+ return {
11141
+ pass,
11142
+ message: () => `Snapshot \`${key || "unknown"}\` mismatched`,
11143
+ actual: rawSnapshot ? actual : actual?.trim(),
11144
+ expected: rawSnapshot ? expected : expected?.trim()
11145
+ };
11146
+ }
11147
+ assert(options) {
11148
+ const result = this.match(options);
11149
+ if (!result.pass) {
11150
+ const snapshotState = this.getSnapshotState(options.filepath);
11151
+ throw createMismatchError(result.message(), snapshotState.expand, result.actual, result.expected);
11152
+ }
11153
+ }
11154
+ matchDomain(options) {
11155
+ const { received, filepath, name, testId = name, message, adapter, isInline = false, inlineSnapshot, error } = options;
11156
+ if (!filepath) throw new Error("Snapshot cannot be used outside of test");
11157
+ const captured = adapter.capture(received);
11158
+ const rendered = adapter.render(captured);
11159
+ const snapshotState = this.getSnapshotState(filepath);
11160
+ const testName = [name, ...message ? [message] : []].join(" > ");
11161
+ const expectedSnapshot = snapshotState.probeExpectedSnapshot({
11162
+ testName,
11163
+ testId,
11164
+ isInline,
11165
+ inlineSnapshot
11166
+ });
11167
+ expectedSnapshot.markAsChecked();
11168
+ const matchResult = expectedSnapshot.data ? adapter.match(captured, adapter.parseExpected(expectedSnapshot.data)) : void 0;
11169
+ const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({
11170
+ testId,
11171
+ received: rendered,
11172
+ expectedSnapshot,
11173
+ matchResult,
11174
+ isInline,
11175
+ error,
11176
+ assertionName: options.assertionName
11177
+ });
11178
+ return {
11179
+ pass,
11180
+ message: () => `Snapshot \`${key}\` mismatched`,
11181
+ actual: actual?.trim(),
11182
+ expected: expected?.trim()
11183
+ };
11184
+ }
11185
+ async pollMatchDomain(options) {
11186
+ const { poll, filepath, name, testId = name, message, adapter, isInline = false, inlineSnapshot, error, timeout = 1e3, interval = 50 } = options;
11187
+ if (!filepath) throw new Error("Snapshot cannot be used outside of test");
11188
+ const snapshotState = this.getSnapshotState(filepath);
11189
+ const testName = [name, ...message ? [message] : []].join(" > ");
11190
+ const expectedSnapshot = snapshotState.probeExpectedSnapshot({
11191
+ testName,
11192
+ testId,
11193
+ isInline,
11194
+ inlineSnapshot
11195
+ });
11196
+ const reference = expectedSnapshot.data && snapshotState.snapshotUpdateState !== "all" ? adapter.parseExpected(expectedSnapshot.data) : void 0;
11197
+ const stableResult = await getStableSnapshot({
11198
+ adapter,
11199
+ poll,
11200
+ interval,
11201
+ timedOut: timeout > 0 ? new Promise((r) => setTimeout(r, timeout)) : void 0,
11202
+ match: reference ? (captured) => adapter.match(captured, reference).pass : void 0
11203
+ });
11204
+ expectedSnapshot.markAsChecked();
11205
+ if (!stableResult?.rendered) {
11206
+ if (stableResult?.lastPollError) throw stableResult.lastPollError;
11207
+ return {
11208
+ pass: false,
11209
+ message: () => `poll() did not produce a stable snapshot within the timeout`
11210
+ };
11211
+ }
11212
+ const matchResult = expectedSnapshot.data ? adapter.match(stableResult.captured, adapter.parseExpected(expectedSnapshot.data)) : void 0;
11213
+ const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({
11214
+ testId,
11215
+ received: stableResult.rendered,
11216
+ expectedSnapshot,
11217
+ matchResult,
11218
+ isInline,
11219
+ error,
11220
+ assertionName: options.assertionName
10952
11221
  });
10953
- if (!pass) throw createMismatchError(`Snapshot \`${key || "unknown"}\` mismatched`, snapshotState.expand, rawSnapshot ? actual : actual?.trim(), rawSnapshot ? expected : expected?.trim());
11222
+ return {
11223
+ pass,
11224
+ message: () => `Snapshot \`${key}\` mismatched`,
11225
+ actual: actual?.trim(),
11226
+ expected: expected?.trim()
11227
+ };
10954
11228
  }
10955
11229
  async assertRaw(options) {
10956
11230
  if (!options.rawSnapshot) throw new Error("Raw snapshot is required");
@@ -10968,395 +11242,79 @@ var SnapshotClient = class {
10968
11242
  this.snapshotStateMap.clear();
10969
11243
  }
10970
11244
  };
10971
- //#endregion
10972
- //#region ../../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
10973
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
10974
- //#endregion
10975
- //#region ../../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js
10976
- var RealDate = Date;
10977
- var now = null;
10978
- var MockDate = class MockDate extends RealDate {
10979
- constructor(y, m, d, h, M, s, ms) {
10980
- super();
10981
- let date;
10982
- switch (arguments.length) {
10983
- case 0:
10984
- if (now !== null) date = new RealDate(now.valueOf());
10985
- else date = new RealDate();
10986
- break;
10987
- case 1:
10988
- date = new RealDate(y);
10989
- break;
10990
- default:
10991
- d = typeof d === "undefined" ? 1 : d;
10992
- h = h || 0;
10993
- M = M || 0;
10994
- s = s || 0;
10995
- ms = ms || 0;
10996
- date = new RealDate(y, m, d, h, M, s, ms);
10997
- break;
11245
+ /**
11246
+ * Polls repeatedly until the value reaches a stable state.
11247
+ *
11248
+ * Compares consecutive rendered outputs from the current session —
11249
+ * when two consecutive polls produce the same rendered string,
11250
+ * the value is considered stable.
11251
+ *
11252
+ * Every `await` (poll call, interval delay) races against `timedOut`
11253
+ * so that hanging polls and delays are interrupted.
11254
+ */
11255
+ async function getStableSnapshot({ adapter, poll, interval, timedOut, match }) {
11256
+ let lastRendered;
11257
+ let lastPollError;
11258
+ let lastStable;
11259
+ while (true) {
11260
+ try {
11261
+ const pollResult = await raceWith(Promise.resolve(poll()), timedOut);
11262
+ if (!pollResult.ok) break;
11263
+ const captured = adapter.capture(pollResult.value);
11264
+ const rendered = adapter.render(captured);
11265
+ if (lastRendered !== void 0 && rendered === lastRendered) {
11266
+ lastStable = {
11267
+ captured,
11268
+ rendered
11269
+ };
11270
+ if (!match || match(captured)) break;
11271
+ } else {
11272
+ lastRendered = rendered;
11273
+ lastStable = void 0;
11274
+ }
11275
+ } catch (pollError) {
11276
+ lastRendered = void 0;
11277
+ lastStable = void 0;
11278
+ lastPollError = pollError;
10998
11279
  }
10999
- Object.setPrototypeOf(date, MockDate.prototype);
11000
- return date;
11280
+ if (!(await raceWith(new Promise((r) => setTimeout(r, interval)), timedOut)).ok) break;
11001
11281
  }
11002
- };
11003
- MockDate.UTC = RealDate.UTC;
11004
- MockDate.now = function() {
11005
- return new MockDate().valueOf();
11006
- };
11007
- MockDate.parse = function(dateString) {
11008
- return RealDate.parse(dateString);
11009
- };
11010
- MockDate.toString = function() {
11011
- return RealDate.toString();
11012
- };
11013
- function mockDate(date) {
11014
- const dateObj = new RealDate(date.valueOf());
11015
- if (Number.isNaN(dateObj.getTime())) throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
11016
- globalThis.Date = MockDate;
11017
- now = dateObj.valueOf();
11018
- }
11019
- function resetDate() {
11020
- globalThis.Date = RealDate;
11282
+ return {
11283
+ ...lastStable,
11284
+ lastPollError
11285
+ };
11021
11286
  }
11022
- var { get } = Reflect;
11023
- function rpc() {
11024
- const { rpc } = getWorkerState();
11025
- return rpc;
11287
+ /** Type-safe `Promise.race` tells you which promise won. */
11288
+ function raceWith(promise, other) {
11289
+ const left = promise.then((value) => ({
11290
+ ok: true,
11291
+ value
11292
+ }));
11293
+ if (!other) return left;
11294
+ return Promise.race([left, other.then((value) => ({
11295
+ ok: false,
11296
+ value
11297
+ }))]);
11026
11298
  }
11027
11299
  //#endregion
11028
- //#region ../../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/dist/chunks/test.p_J6dB8a.js
11029
- var unsupported = [
11030
- "matchSnapshot",
11031
- "toMatchSnapshot",
11032
- "toMatchInlineSnapshot",
11033
- "toThrowErrorMatchingSnapshot",
11034
- "toThrowErrorMatchingInlineSnapshot",
11035
- "throws",
11036
- "Throw",
11037
- "throw",
11038
- "toThrow",
11039
- "toThrowError"
11040
- ];
11041
- /**
11042
- * Attaches a `cause` property to the error if missing, copies the stack trace from the source, and throws.
11043
- *
11044
- * @param error - The error to throw
11045
- * @param source - Error to copy the stack trace from
11046
- *
11047
- * @throws Always throws the provided error with an amended stack trace
11048
- */
11049
- function throwWithCause(error, source) {
11050
- if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
11051
- throw copyStackTrace$1(error, source);
11052
- }
11053
- function createExpectPoll(expect) {
11054
- return function poll(fn, options = {}) {
11055
- const defaults = getWorkerState().config.expect?.poll ?? {};
11056
- const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
11057
- const assertion = expect(null, message).withContext({ poll: true });
11058
- fn = fn.bind(assertion);
11059
- const test = utils_exports.flag(assertion, "vitest-test");
11060
- if (!test) throw new Error("expect.poll() must be called inside a test");
11061
- const proxy = new Proxy(assertion, { get(target, key, receiver) {
11062
- const assertionFunction = Reflect.get(target, key, receiver);
11063
- if (typeof assertionFunction !== "function") return assertionFunction instanceof Assertion ? proxy : assertionFunction;
11064
- if (key === "assert") return assertionFunction;
11065
- if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
11066
- return function(...args) {
11067
- const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
11068
- const promise = async () => {
11069
- const { setTimeout, clearTimeout } = getSafeTimers();
11070
- let executionPhase = "fn";
11071
- let hasTimedOut = false;
11072
- const timerId = setTimeout(() => {
11073
- hasTimedOut = true;
11074
- }, timeout);
11075
- utils_exports.flag(assertion, "_name", key);
11076
- const onSettled = utils_exports.flag(assertion, "_poll.onSettled");
11077
- try {
11078
- while (true) {
11079
- const isLastAttempt = hasTimedOut;
11080
- if (isLastAttempt) utils_exports.flag(assertion, "_isLastPollAttempt", true);
11081
- try {
11082
- executionPhase = "fn";
11083
- const obj = await fn();
11084
- utils_exports.flag(assertion, "object", obj);
11085
- executionPhase = "assertion";
11086
- const output = await assertionFunction.call(assertion, ...args);
11087
- await onSettled?.({
11088
- assertion,
11089
- status: "pass"
11090
- });
11091
- return output;
11092
- } catch (err) {
11093
- if (isLastAttempt || executionPhase === "assertion" && utils_exports.flag(assertion, "_poll.assert_once")) {
11094
- await onSettled?.({
11095
- assertion,
11096
- status: "fail"
11097
- });
11098
- throwWithCause(err, STACK_TRACE_ERROR);
11099
- }
11100
- await delay(interval, setTimeout);
11101
- }
11102
- }
11103
- } finally {
11104
- clearTimeout(timerId);
11105
- }
11106
- };
11107
- let awaited = false;
11108
- test.onFinished ??= [];
11109
- test.onFinished.push(() => {
11110
- if (!awaited) {
11111
- const negated = utils_exports.flag(assertion, "negate") ? "not." : "";
11112
- const assertionString = `expect.${utils_exports.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`;
11113
- throw copyStackTrace$1(/* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`), STACK_TRACE_ERROR);
11114
- }
11115
- });
11116
- let resultPromise;
11117
- return {
11118
- then(onFulfilled, onRejected) {
11119
- awaited = true;
11120
- return (resultPromise ||= promise()).then(onFulfilled, onRejected);
11121
- },
11122
- catch(onRejected) {
11123
- awaited = true;
11124
- return (resultPromise ||= promise()).catch(onRejected);
11125
- },
11126
- finally(onFinally) {
11127
- awaited = true;
11128
- return (resultPromise ||= promise()).finally(onFinally);
11129
- },
11130
- [Symbol.toStringTag]: "Promise"
11131
- };
11132
- };
11133
- } });
11134
- return proxy;
11135
- };
11136
- }
11137
- function copyStackTrace$1(target, source) {
11138
- if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
11139
- return target;
11140
- }
11141
- var _client;
11142
- function getSnapshotClient() {
11143
- if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
11144
- return equals(received, expected, [iterableEquality, subsetEquality]);
11145
- } });
11146
- return _client;
11147
- }
11148
- function getError(expected, promise) {
11149
- if (typeof expected !== "function") {
11150
- if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
11151
- return expected;
11152
- }
11153
- try {
11154
- expected();
11155
- } catch (e) {
11156
- return e;
11157
- }
11158
- throw new Error("snapshot function didn't throw");
11159
- }
11160
- function getTestNames(test) {
11161
- return {
11162
- filepath: test.file.filepath,
11163
- name: getNames(test).slice(1).join(" > "),
11164
- testId: test.id
11165
- };
11166
- }
11167
- var SnapshotPlugin = (chai, utils) => {
11168
- function getTest(assertionName, obj) {
11169
- const test = utils.flag(obj, "vitest-test");
11170
- if (!test) throw new Error(`'${assertionName}' cannot be used without test context`);
11171
- return test;
11172
- }
11173
- for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai.Assertion.prototype, key, wrapAssertion(utils, key, function(properties, message) {
11174
- utils.flag(this, "_name", key);
11175
- if (utils.flag(this, "negate")) throw new Error(`${key} cannot be used with "not"`);
11176
- const expected = utils.flag(this, "object");
11177
- const test = getTest(key, this);
11178
- if (typeof properties === "string" && typeof message === "undefined") {
11179
- message = properties;
11180
- properties = void 0;
11181
- }
11182
- const errorMessage = utils.flag(this, "message");
11183
- getSnapshotClient().assert({
11184
- received: expected,
11185
- message,
11186
- isInline: false,
11187
- properties,
11188
- errorMessage,
11189
- ...getTestNames(test)
11190
- });
11191
- }));
11192
- utils.addMethod(chai.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
11193
- utils.flag(this, "_name", "toMatchFileSnapshot");
11194
- if (utils.flag(this, "negate")) throw new Error("toMatchFileSnapshot cannot be used with \"not\"");
11195
- const error = /* @__PURE__ */ new Error("resolves");
11196
- const expected = utils.flag(this, "object");
11197
- const test = getTest("toMatchFileSnapshot", this);
11198
- const errorMessage = utils.flag(this, "message");
11199
- return recordAsyncExpect(test, getSnapshotClient().assertRaw({
11200
- received: expected,
11201
- message,
11202
- isInline: false,
11203
- rawSnapshot: { file },
11204
- errorMessage,
11205
- ...getTestNames(test)
11206
- }), createAssertionMessage(utils, this, true), error, utils.flag(this, "soft"));
11207
- });
11208
- utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", wrapAssertion(utils, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(properties, inlineSnapshot, message) {
11209
- utils.flag(this, "_name", "toMatchInlineSnapshot");
11210
- if (utils.flag(this, "negate")) throw new Error("toMatchInlineSnapshot cannot be used with \"not\"");
11211
- const test = getTest("toMatchInlineSnapshot", this);
11212
- const expected = utils.flag(this, "object");
11213
- const error = utils.flag(this, "error");
11214
- if (typeof properties === "string") {
11215
- message = inlineSnapshot;
11216
- inlineSnapshot = properties;
11217
- properties = void 0;
11218
- }
11219
- if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
11220
- const errorMessage = utils.flag(this, "message");
11221
- getSnapshotClient().assert({
11222
- received: expected,
11223
- message,
11224
- isInline: true,
11225
- properties,
11226
- inlineSnapshot,
11227
- error,
11228
- errorMessage,
11229
- ...getTestNames(test)
11230
- });
11231
- }));
11232
- utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", wrapAssertion(utils, "toThrowErrorMatchingSnapshot", function(properties, message) {
11233
- utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
11234
- if (utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingSnapshot cannot be used with \"not\"");
11235
- const expected = utils.flag(this, "object");
11236
- const test = getTest("toThrowErrorMatchingSnapshot", this);
11237
- const promise = utils.flag(this, "promise");
11238
- const errorMessage = utils.flag(this, "message");
11239
- getSnapshotClient().assert({
11240
- received: getError(expected, promise),
11241
- message,
11242
- errorMessage,
11243
- ...getTestNames(test)
11244
- });
11245
- }));
11246
- utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", wrapAssertion(utils, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(inlineSnapshot, message) {
11247
- if (utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingInlineSnapshot cannot be used with \"not\"");
11248
- const test = getTest("toThrowErrorMatchingInlineSnapshot", this);
11249
- const expected = utils.flag(this, "object");
11250
- const error = utils.flag(this, "error");
11251
- const promise = utils.flag(this, "promise");
11252
- const errorMessage = utils.flag(this, "message");
11253
- if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
11254
- getSnapshotClient().assert({
11255
- received: getError(expected, promise),
11256
- message,
11257
- inlineSnapshot,
11258
- isInline: true,
11259
- error,
11260
- errorMessage,
11261
- ...getTestNames(test)
11262
- });
11263
- }));
11264
- utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
11265
- };
11266
- use(JestExtend);
11267
- use(JestChaiExpect);
11268
- use(ChaiStyleAssertions);
11269
- use(SnapshotPlugin);
11270
- use(JestAsymmetricMatchers);
11271
- function createExpect(test) {
11272
- const expect$1 = ((value, message) => {
11273
- const { assertionCalls } = getState(expect$1);
11274
- setState({ assertionCalls: assertionCalls + 1 }, expect$1);
11275
- const assert = expect(value, message);
11276
- const _test = test || getCurrentTest();
11277
- if (_test) return assert.withTest(_test);
11278
- else return assert;
11279
- });
11280
- Object.assign(expect$1, expect);
11281
- Object.assign(expect$1, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
11282
- expect$1.getState = () => getState(expect$1);
11283
- expect$1.setState = (state) => setState(state, expect$1);
11284
- const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
11285
- setState({
11286
- ...globalState,
11287
- assertionCalls: 0,
11288
- isExpectingAssertions: false,
11289
- isExpectingAssertionsError: null,
11290
- expectedAssertionsNumber: null,
11291
- expectedAssertionsNumberErrorGen: null,
11292
- get testPath() {
11293
- return getWorkerState().filepath;
11294
- },
11295
- currentTestName: test ? test.fullTestName ?? "" : globalState.currentTestName
11296
- }, expect$1);
11297
- expect$1.assert = assert$1;
11298
- expect$1.extend = (matchers) => expect.extend(expect$1, matchers);
11299
- expect$1.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
11300
- expect$1.soft = (...args) => {
11301
- return expect$1(...args).withContext({ soft: true });
11302
- };
11303
- expect$1.poll = createExpectPoll(expect$1);
11304
- expect$1.unreachable = (message) => {
11305
- assert$1.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
11306
- };
11307
- function assertions(expected) {
11308
- const errorGen = () => /* @__PURE__ */ new Error(`expected number of assertions to be ${expected}, but got ${expect$1.getState().assertionCalls}`);
11309
- if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
11310
- expect$1.setState({
11311
- expectedAssertionsNumber: expected,
11312
- expectedAssertionsNumberErrorGen: errorGen
11313
- });
11314
- }
11315
- function hasAssertions() {
11316
- const error = /* @__PURE__ */ new Error("expected any number of assertion, but got none");
11317
- if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
11318
- expect$1.setState({
11319
- isExpectingAssertions: true,
11320
- isExpectingAssertionsError: error
11321
- });
11322
- }
11323
- utils_exports.addMethod(expect$1, "assertions", assertions);
11324
- utils_exports.addMethod(expect$1, "hasAssertions", hasAssertions);
11325
- expect$1.extend(customMatchers);
11326
- return expect$1;
11327
- }
11328
- var globalExpect = createExpect();
11329
- Object.defineProperty(globalThis, GLOBAL_EXPECT, {
11330
- value: globalExpect,
11331
- writable: true,
11332
- configurable: true
11333
- });
11334
- var assert = assert$1;
11335
- var should = should$1;
11336
- /**
11337
- * Gives access to injected context provided from the main thread.
11338
- * This usually returns a value provided by `globalSetup` or an external library.
11339
- */
11340
- function inject(key) {
11341
- return getWorkerState().providedContext[key];
11342
- }
11343
- var fakeTimersSrc = {};
11344
- var global$1;
11345
- var hasRequiredGlobal;
11346
- function requireGlobal() {
11347
- if (hasRequiredGlobal) return global$1;
11348
- hasRequiredGlobal = 1;
11349
- /**
11350
- * A reference to the global object
11351
- * @type {object} globalObject
11352
- */
11353
- var globalObject;
11354
- /* istanbul ignore else */
11355
- if (typeof commonjsGlobal !== "undefined") globalObject = commonjsGlobal;
11356
- else if (typeof window !== "undefined") globalObject = window;
11357
- else globalObject = self;
11358
- global$1 = globalObject;
11359
- return global$1;
11300
+ //#region ../../../node_modules/.pnpm/vitest@4.1.4_@opentelemetry+api@1.9.0_@types+node@25.6.0_happy-dom@20.8.9_jsdom@29.0.1__4c3ad3159a5d6ab290fe85c67b420ce9/node_modules/vitest/dist/chunks/test.D1JkM1w4.js
11301
+ var fakeTimersSrc = {};
11302
+ var global$1;
11303
+ var hasRequiredGlobal;
11304
+ function requireGlobal() {
11305
+ if (hasRequiredGlobal) return global$1;
11306
+ hasRequiredGlobal = 1;
11307
+ /**
11308
+ * A reference to the global object
11309
+ * @type {object} globalObject
11310
+ */
11311
+ var globalObject;
11312
+ /* istanbul ignore else */
11313
+ if (typeof commonjsGlobal !== "undefined") globalObject = commonjsGlobal;
11314
+ else if (typeof window !== "undefined") globalObject = window;
11315
+ else globalObject = self;
11316
+ global$1 = globalObject;
11317
+ return global$1;
11360
11318
  }
11361
11319
  var throwsOnProto_1;
11362
11320
  var hasRequiredThrowsOnProto;
@@ -13334,7 +13292,7 @@ var FakeTimers = class {
13334
13292
  return this._fakingTime;
13335
13293
  }
13336
13294
  };
13337
- function copyStackTrace(target, source) {
13295
+ function copyStackTrace$1(target, source) {
13338
13296
  if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
13339
13297
  return target;
13340
13298
  }
@@ -13355,7 +13313,7 @@ function waitFor(callback, options = {}) {
13355
13313
  const handleTimeout = () => {
13356
13314
  if (intervalId) clearInterval(intervalId);
13357
13315
  let error = lastError;
13358
- if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
13316
+ if (!error) error = copyStackTrace$1(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
13359
13317
  reject(error);
13360
13318
  };
13361
13319
  const checkCallback = () => {
@@ -13396,7 +13354,7 @@ function waitUntil(callback, options = {}) {
13396
13354
  let intervalId;
13397
13355
  const onReject = (error) => {
13398
13356
  if (intervalId) clearInterval(intervalId);
13399
- if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
13357
+ if (!error) error = copyStackTrace$1(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
13400
13358
  reject(error);
13401
13359
  };
13402
13360
  const onResolve = (result) => {
@@ -13662,6 +13620,450 @@ function getImporter(name) {
13662
13620
  return stack.includes(` at Object.${name}`) || stack.includes(`${name}@`) || stack.includes(` at ${name} (`);
13663
13621
  }) + 1])?.file || "";
13664
13622
  }
13623
+ var unsupported = [
13624
+ "matchSnapshot",
13625
+ "toMatchSnapshot",
13626
+ "toMatchInlineSnapshot",
13627
+ "toThrowErrorMatchingSnapshot",
13628
+ "toThrowErrorMatchingInlineSnapshot",
13629
+ "throws",
13630
+ "Throw",
13631
+ "throw",
13632
+ "toThrow",
13633
+ "toThrowError"
13634
+ ];
13635
+ /**
13636
+ * Attaches a `cause` property to the error if missing, copies the stack trace from the source, and throws.
13637
+ *
13638
+ * @param error - The error to throw
13639
+ * @param source - Error to copy the stack trace from
13640
+ *
13641
+ * @throws Always throws the provided error with an amended stack trace
13642
+ */
13643
+ function throwWithCause(error, source) {
13644
+ if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
13645
+ throw copyStackTrace(error, source);
13646
+ }
13647
+ function createExpectPoll(expect) {
13648
+ return function poll(fn, options = {}) {
13649
+ const defaults = getWorkerState().config.expect?.poll ?? {};
13650
+ const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
13651
+ const assertion = expect(null, message).withContext({ poll: true });
13652
+ fn = fn.bind(assertion);
13653
+ utils_exports.flag(assertion, "_poll.fn", fn);
13654
+ utils_exports.flag(assertion, "_poll.timeout", timeout);
13655
+ utils_exports.flag(assertion, "_poll.interval", interval);
13656
+ const test = utils_exports.flag(assertion, "vitest-test");
13657
+ if (!test) throw new Error("expect.poll() must be called inside a test");
13658
+ const proxy = new Proxy(assertion, { get(target, key, receiver) {
13659
+ const assertionFunction = Reflect.get(target, key, receiver);
13660
+ if (typeof assertionFunction !== "function") return assertionFunction instanceof Assertion ? proxy : assertionFunction;
13661
+ if (key === "assert") return assertionFunction;
13662
+ if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
13663
+ return function __VITEST_POLL_CHAIN__(...args) {
13664
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
13665
+ const promise = async () => {
13666
+ utils_exports.flag(assertion, "_name", key);
13667
+ utils_exports.flag(assertion, "error", STACK_TRACE_ERROR);
13668
+ const onSettled = utils_exports.flag(assertion, "_poll.onSettled");
13669
+ if (Object.getOwnPropertyDescriptor(assertionFunction, "__vitest_poll_takeover__")?.value) try {
13670
+ const output = await assertionFunction.call(assertion, ...args);
13671
+ await onSettled?.({
13672
+ assertion,
13673
+ status: "pass"
13674
+ });
13675
+ return output;
13676
+ } catch (err) {
13677
+ await onSettled?.({
13678
+ assertion,
13679
+ status: "fail"
13680
+ });
13681
+ throwWithCause(err, STACK_TRACE_ERROR);
13682
+ }
13683
+ const { setTimeout, clearTimeout } = getSafeTimers();
13684
+ let executionPhase = "fn";
13685
+ let hasTimedOut = false;
13686
+ const timerId = setTimeout(() => {
13687
+ hasTimedOut = true;
13688
+ }, timeout);
13689
+ try {
13690
+ while (true) {
13691
+ const isLastAttempt = hasTimedOut;
13692
+ if (isLastAttempt) utils_exports.flag(assertion, "_isLastPollAttempt", true);
13693
+ try {
13694
+ executionPhase = "fn";
13695
+ const obj = await fn();
13696
+ utils_exports.flag(assertion, "object", obj);
13697
+ executionPhase = "assertion";
13698
+ const output = await assertionFunction.call(assertion, ...args);
13699
+ await onSettled?.({
13700
+ assertion,
13701
+ status: "pass"
13702
+ });
13703
+ return output;
13704
+ } catch (err) {
13705
+ if (isLastAttempt || executionPhase === "assertion" && utils_exports.flag(assertion, "_poll.assert_once")) {
13706
+ await onSettled?.({
13707
+ assertion,
13708
+ status: "fail"
13709
+ });
13710
+ throwWithCause(err, STACK_TRACE_ERROR);
13711
+ }
13712
+ await delay(interval, setTimeout);
13713
+ if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
13714
+ }
13715
+ }
13716
+ } finally {
13717
+ clearTimeout(timerId);
13718
+ }
13719
+ };
13720
+ let awaited = false;
13721
+ test.onFinished ??= [];
13722
+ test.onFinished.push(() => {
13723
+ if (!awaited) {
13724
+ const negated = utils_exports.flag(assertion, "negate") ? "not." : "";
13725
+ const assertionString = `expect.${utils_exports.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`;
13726
+ throw copyStackTrace(/* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`), STACK_TRACE_ERROR);
13727
+ }
13728
+ });
13729
+ let resultPromise;
13730
+ return {
13731
+ then(onFulfilled, onRejected) {
13732
+ awaited = true;
13733
+ return (resultPromise ||= promise()).then(onFulfilled, onRejected);
13734
+ },
13735
+ catch(onRejected) {
13736
+ awaited = true;
13737
+ return (resultPromise ||= promise()).catch(onRejected);
13738
+ },
13739
+ finally(onFinally) {
13740
+ awaited = true;
13741
+ return (resultPromise ||= promise()).finally(onFinally);
13742
+ },
13743
+ [Symbol.toStringTag]: "Promise"
13744
+ };
13745
+ };
13746
+ } });
13747
+ return proxy;
13748
+ };
13749
+ }
13750
+ function copyStackTrace(target, source) {
13751
+ if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
13752
+ return target;
13753
+ }
13754
+ var _client;
13755
+ function getSnapshotClient() {
13756
+ if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
13757
+ return equals(received, expected, [iterableEquality, subsetEquality]);
13758
+ } });
13759
+ return _client;
13760
+ }
13761
+ function getError(expected, promise) {
13762
+ if (typeof expected !== "function") {
13763
+ if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
13764
+ return expected;
13765
+ }
13766
+ try {
13767
+ expected();
13768
+ } catch (e) {
13769
+ return e;
13770
+ }
13771
+ throw new Error("snapshot function didn't throw");
13772
+ }
13773
+ function getTestNames(test) {
13774
+ return {
13775
+ filepath: test.file.filepath,
13776
+ name: getNames(test).slice(1).join(" > "),
13777
+ testId: test.id
13778
+ };
13779
+ }
13780
+ function getAssertionName(assertion) {
13781
+ const name = utils_exports.flag(assertion, "_name");
13782
+ if (!name) throw new Error("Assertion name is not set. This is a bug in Vitest. Please, open a new issue with reproduction.");
13783
+ return name;
13784
+ }
13785
+ function getTest(obj) {
13786
+ const test = utils_exports.flag(obj, "vitest-test");
13787
+ if (!test) throw new Error(`'${getAssertionName(obj)}' cannot be used without test context`);
13788
+ return test;
13789
+ }
13790
+ function validateAssertion(assertion) {
13791
+ if (utils_exports.flag(assertion, "negate")) throw new Error(`${getAssertionName(assertion)} cannot be used with "not"`);
13792
+ }
13793
+ var SnapshotPlugin = (chai, utils) => {
13794
+ for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai.Assertion.prototype, key, wrapAssertion(utils, key, function(propertiesOrHint, hint) {
13795
+ return assertMatchResult(toMatchSnapshotImpl({
13796
+ assertion: this,
13797
+ received: utils.flag(this, "object"),
13798
+ ...normalizeArguments(propertiesOrHint, hint)
13799
+ }), chai.util.flag(this, "message"));
13800
+ }));
13801
+ utils.addMethod(chai.Assertion.prototype, "toMatchFileSnapshot", function(filepath, hint) {
13802
+ utils.flag(this, "_name", "toMatchFileSnapshot");
13803
+ validateAssertion(this);
13804
+ const assertPromise = toMatchFileSnapshotImpl({
13805
+ assertion: this,
13806
+ received: utils.flag(this, "object"),
13807
+ filepath,
13808
+ hint
13809
+ }).then((result) => assertMatchResult(result, chai.util.flag(this, "message")));
13810
+ return recordAsyncExpect(getTest(this), assertPromise, createAssertionMessage(utils, this, true), /* @__PURE__ */ new Error("resolves"), utils.flag(this, "soft"));
13811
+ });
13812
+ utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", wrapAssertion(utils, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
13813
+ return assertMatchResult(toMatchSnapshotImpl({
13814
+ assertion: this,
13815
+ received: utils.flag(this, "object"),
13816
+ isInline: true,
13817
+ ...normalizeInlineArguments(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint)
13818
+ }), chai.util.flag(this, "message"));
13819
+ }));
13820
+ utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", wrapAssertion(utils, "toThrowErrorMatchingSnapshot", function(propertiesOrHint, hint) {
13821
+ validateAssertion(this);
13822
+ const received = utils.flag(this, "object");
13823
+ const promise = utils.flag(this, "promise");
13824
+ return assertMatchResult(toMatchSnapshotImpl({
13825
+ assertion: this,
13826
+ received: getError(received, promise),
13827
+ ...normalizeArguments(propertiesOrHint, hint)
13828
+ }), chai.util.flag(this, "message"));
13829
+ }));
13830
+ utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", wrapAssertion(utils, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(inlineSnapshotOrHint, hint) {
13831
+ validateAssertion(this);
13832
+ const received = utils.flag(this, "object");
13833
+ const promise = utils.flag(this, "promise");
13834
+ return assertMatchResult(toMatchSnapshotImpl({
13835
+ assertion: this,
13836
+ received: getError(received, promise),
13837
+ isInline: true,
13838
+ ...normalizeInlineArguments(void 0, inlineSnapshotOrHint, hint)
13839
+ }), chai.util.flag(this, "message"));
13840
+ }));
13841
+ utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
13842
+ };
13843
+ function toMatchDomainSnapshotImpl(opts) {
13844
+ const { assertion } = opts;
13845
+ validateAssertion(assertion);
13846
+ const assertionName = getAssertionName(assertion);
13847
+ const test = getTest(assertion);
13848
+ let { inlineSnapshot } = opts;
13849
+ if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
13850
+ const pollFn = utils_exports.flag(assertion, "_poll.fn");
13851
+ if (pollFn) return getSnapshotClient().pollMatchDomain({
13852
+ poll: pollFn,
13853
+ adapter: opts.adapter,
13854
+ message: opts.hint,
13855
+ isInline: opts.isInline,
13856
+ errorMessage: utils_exports.flag(assertion, "message"),
13857
+ timeout: utils_exports.flag(assertion, "_poll.timeout"),
13858
+ interval: utils_exports.flag(assertion, "_poll.interval"),
13859
+ assertionName,
13860
+ inlineSnapshot,
13861
+ error: utils_exports.flag(assertion, "error"),
13862
+ ...getTestNames(test)
13863
+ });
13864
+ return getSnapshotClient().matchDomain({
13865
+ received: opts.received,
13866
+ adapter: opts.adapter,
13867
+ message: opts.hint,
13868
+ isInline: opts.isInline,
13869
+ errorMessage: utils_exports.flag(assertion, "message"),
13870
+ assertionName,
13871
+ inlineSnapshot,
13872
+ error: utils_exports.flag(assertion, "error"),
13873
+ ...getTestNames(test)
13874
+ });
13875
+ }
13876
+ function normalizeArguments(propertiesOrHint, hint) {
13877
+ if (typeof propertiesOrHint === "string") return { hint: propertiesOrHint };
13878
+ return {
13879
+ properties: propertiesOrHint,
13880
+ hint
13881
+ };
13882
+ }
13883
+ function normalizeInlineArguments(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
13884
+ let inlineSnapshot;
13885
+ if (typeof propertiesOrInlineSnapshot === "string") {
13886
+ inlineSnapshot = stripSnapshotIndentation(propertiesOrInlineSnapshot);
13887
+ return {
13888
+ inlineSnapshot,
13889
+ hint: inlineSnapshotOrHint
13890
+ };
13891
+ }
13892
+ if (inlineSnapshotOrHint) inlineSnapshot = stripSnapshotIndentation(inlineSnapshotOrHint);
13893
+ return {
13894
+ properties: propertiesOrInlineSnapshot,
13895
+ inlineSnapshot,
13896
+ hint
13897
+ };
13898
+ }
13899
+ function toMatchSnapshotImpl(options) {
13900
+ const { assertion } = options;
13901
+ validateAssertion(assertion);
13902
+ const assertionName = getAssertionName(assertion);
13903
+ const test = getTest(assertion);
13904
+ return getSnapshotClient().match({
13905
+ received: options.received,
13906
+ properties: options.properties,
13907
+ message: options.hint,
13908
+ isInline: options.isInline,
13909
+ inlineSnapshot: options.inlineSnapshot,
13910
+ assertionName,
13911
+ error: utils_exports.flag(assertion, "error"),
13912
+ ...getTestNames(test)
13913
+ });
13914
+ }
13915
+ async function toMatchFileSnapshotImpl(options) {
13916
+ const { assertion } = options;
13917
+ validateAssertion(assertion);
13918
+ const testNames = getTestNames(getTest(assertion));
13919
+ const snapshotState = getSnapshotClient().getSnapshotState(testNames.filepath);
13920
+ const rawSnapshotFile = await snapshotState.environment.resolveRawPath(testNames.filepath, options.filepath);
13921
+ const rawSnapshotContent = await snapshotState.environment.readSnapshotFile(rawSnapshotFile);
13922
+ return getSnapshotClient().match({
13923
+ received: options.received,
13924
+ message: options.hint,
13925
+ rawSnapshot: {
13926
+ file: rawSnapshotFile,
13927
+ content: rawSnapshotContent ?? void 0
13928
+ },
13929
+ ...testNames
13930
+ });
13931
+ }
13932
+ function assertMatchResult(result, customMessage) {
13933
+ if (!result.pass) {
13934
+ const errorMessage = (customMessage ? `${customMessage}: ` : "") + result.message();
13935
+ throw Object.assign(new Error(errorMessage), {
13936
+ actual: result.actual,
13937
+ expected: result.expected,
13938
+ diffOptions: { expand: getWorkerState().config.snapshotOptions.expand }
13939
+ });
13940
+ }
13941
+ }
13942
+ /**
13943
+ * Composable snapshot matcher helpers for building custom snapshot matchers
13944
+ * with `expect.extend`.
13945
+ *
13946
+ * @experimental
13947
+ * @see https://vitest.dev/guide/snapshot.html#custom-snapshot-matchers
13948
+ */
13949
+ var Snapshots = {
13950
+ toMatchSnapshot(received, propertiesOrHint, hint) {
13951
+ return toMatchSnapshotImpl({
13952
+ assertion: this.assertion,
13953
+ received,
13954
+ ...normalizeArguments(propertiesOrHint, hint)
13955
+ });
13956
+ },
13957
+ toMatchInlineSnapshot(received, propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
13958
+ return toMatchSnapshotImpl({
13959
+ assertion: this.assertion,
13960
+ received,
13961
+ isInline: true,
13962
+ ...normalizeInlineArguments(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint)
13963
+ });
13964
+ },
13965
+ toMatchFileSnapshot(received, filepath, hint) {
13966
+ return toMatchFileSnapshotImpl({
13967
+ assertion: this.assertion,
13968
+ received,
13969
+ filepath,
13970
+ hint
13971
+ });
13972
+ },
13973
+ toMatchDomainSnapshot(domain, received) {
13974
+ return toMatchDomainSnapshotImpl({
13975
+ assertion: this.assertion,
13976
+ adapter: domain,
13977
+ received
13978
+ });
13979
+ },
13980
+ toMatchDomainInlineSnapshot(domain, received, inlineSnapshot) {
13981
+ return toMatchDomainSnapshotImpl({
13982
+ assertion: this.assertion,
13983
+ adapter: domain,
13984
+ received,
13985
+ isInline: true,
13986
+ inlineSnapshot
13987
+ });
13988
+ }
13989
+ };
13990
+ use(JestExtend);
13991
+ use(JestChaiExpect);
13992
+ use(ChaiStyleAssertions);
13993
+ use(SnapshotPlugin);
13994
+ use(JestAsymmetricMatchers);
13995
+ function createExpect(test) {
13996
+ const expect$1 = ((value, message) => {
13997
+ const { assertionCalls } = getState(expect$1);
13998
+ setState({ assertionCalls: assertionCalls + 1 }, expect$1);
13999
+ const assert = expect(value, message);
14000
+ const _test = test || getCurrentTest();
14001
+ if (_test) return assert.withTest(_test);
14002
+ else return assert;
14003
+ });
14004
+ Object.assign(expect$1, expect);
14005
+ Object.assign(expect$1, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
14006
+ expect$1.getState = () => getState(expect$1);
14007
+ expect$1.setState = (state) => setState(state, expect$1);
14008
+ const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
14009
+ setState({
14010
+ ...globalState,
14011
+ assertionCalls: 0,
14012
+ isExpectingAssertions: false,
14013
+ isExpectingAssertionsError: null,
14014
+ expectedAssertionsNumber: null,
14015
+ expectedAssertionsNumberErrorGen: null,
14016
+ get testPath() {
14017
+ return getWorkerState().filepath;
14018
+ },
14019
+ currentTestName: test ? test.fullTestName ?? "" : globalState.currentTestName
14020
+ }, expect$1);
14021
+ expect$1.assert = assert$1;
14022
+ expect$1.extend = (matchers) => expect.extend(expect$1, matchers);
14023
+ expect$1.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
14024
+ expect$1.soft = (...args) => {
14025
+ return expect$1(...args).withContext({ soft: true });
14026
+ };
14027
+ expect$1.poll = createExpectPoll(expect$1);
14028
+ expect$1.unreachable = (message) => {
14029
+ assert$1.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
14030
+ };
14031
+ function assertions(expected) {
14032
+ const errorGen = () => /* @__PURE__ */ new Error(`expected number of assertions to be ${expected}, but got ${expect$1.getState().assertionCalls}`);
14033
+ if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
14034
+ expect$1.setState({
14035
+ expectedAssertionsNumber: expected,
14036
+ expectedAssertionsNumberErrorGen: errorGen
14037
+ });
14038
+ }
14039
+ function hasAssertions() {
14040
+ const error = /* @__PURE__ */ new Error("expected any number of assertion, but got none");
14041
+ if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
14042
+ expect$1.setState({
14043
+ isExpectingAssertions: true,
14044
+ isExpectingAssertionsError: error
14045
+ });
14046
+ }
14047
+ utils_exports.addMethod(expect$1, "assertions", assertions);
14048
+ utils_exports.addMethod(expect$1, "hasAssertions", hasAssertions);
14049
+ expect$1.extend(customMatchers);
14050
+ return expect$1;
14051
+ }
14052
+ var globalExpect = createExpect();
14053
+ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
14054
+ value: globalExpect,
14055
+ writable: true,
14056
+ configurable: true
14057
+ });
14058
+ var assert = assert$1;
14059
+ var should = should$1;
14060
+ /**
14061
+ * Gives access to injected context provided from the main thread.
14062
+ * This usually returns a value provided by `globalSetup` or an external library.
14063
+ */
14064
+ function inject(key) {
14065
+ return getWorkerState().providedContext[key];
14066
+ }
13665
14067
  function createBenchmarkResult(name) {
13666
14068
  return {
13667
14069
  name,
@@ -13914,7 +14316,7 @@ function clearModuleMocks(config) {
13914
14316
  if (unstubGlobals) vi.unstubAllGlobals();
13915
14317
  }
13916
14318
  //#endregion
13917
- //#region ../../../node_modules/.pnpm/vite@8.0.3_@types+node@25.5.2_esbuild@0.27.4_jiti@2.6.1_tsx@4.21.0/node_modules/vite/dist/node/module-runner.js
14319
+ //#region ../../../node_modules/.pnpm/vite@8.0.8_@types+node@25.6.0_esbuild@0.28.0_jiti@2.6.1_tsx@4.21.0/node_modules/vite/dist/node/module-runner.js
13918
14320
  var SOURCEMAPPING_URL = "sourceMa";
13919
14321
  SOURCEMAPPING_URL += "ppingURL";
13920
14322
  var isWindows = typeof process < "u" && process.platform === "win32";
@@ -14119,7 +14521,7 @@ new Proxy({}, { get(_, p) {
14119
14521
  throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
14120
14522
  } });
14121
14523
  //#endregion
14122
- //#region ../../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js
14524
+ //#region ../../../node_modules/.pnpm/vitest@4.1.4_@opentelemetry+api@1.9.0_@types+node@25.6.0_happy-dom@20.8.9_jsdom@29.0.1__4c3ad3159a5d6ab290fe85c67b420ce9/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js
14123
14525
  var VitestEvaluatedModules = class extends EvaluatedModules {
14124
14526
  getModuleSourceMapById(id) {
14125
14527
  const map = super.getModuleSourceMapById(id);
@@ -14152,7 +14554,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
14152
14554
  Object.defineProperty(exports, "__esModule", { value: true });
14153
14555
  }));
14154
14556
  //#endregion
14155
- //#region ../../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.5.2_happy-dom@18.0.1_jsdom@29.0.1__cf001624456b7837f7b99c4ef7b4c061/node_modules/vitest/dist/chunks/index.DOa3dzoN.js
14557
+ //#region ../../../node_modules/.pnpm/vitest@4.1.4_@opentelemetry+api@1.9.0_@types+node@25.6.0_happy-dom@20.8.9_jsdom@29.0.1__4c3ad3159a5d6ab290fe85c67b420ce9/node_modules/vitest/dist/chunks/index.C-zNJvRx.js
14156
14558
  var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
14157
14559
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
14158
14560
  if (k2 === void 0) k2 = k;
@@ -14254,6 +14656,6 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
14254
14656
  var assertType = function assertType() {};
14255
14657
  //#endregion
14256
14658
  var expectTypeOf = import_dist.expectTypeOf;
14257
- export { NodeBenchmarkRunner as BenchmarkRunner, VitestEvaluatedModules as EvaluatedModules, TestRunner, afterAll, afterEach, aroundAll, aroundEach, assert, assertType, beforeAll, beforeEach, bench, chai_exports as chai, createExpect, describe, globalExpect as expect, expectTypeOf, inject, it, onTestFailed, onTestFinished, recordArtifact, should, suite, test, vi, vitest };
14659
+ export { NodeBenchmarkRunner as BenchmarkRunner, VitestEvaluatedModules as EvaluatedModules, Snapshots, TestRunner, afterAll, afterEach, aroundAll, aroundEach, assert, assertType, beforeAll, beforeEach, bench, chai_exports as chai, createExpect, describe, globalExpect as expect, expectTypeOf, inject, it, onTestFailed, onTestFinished, recordArtifact, should, suite, test, vi, vitest };
14258
14660
 
14259
14661
  //# sourceMappingURL=vitest.js.map