@procore/hammer-test-jest 0.3.0 → 0.4.0

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.
@@ -7857,7 +7857,14 @@ function clone(val, seen, options = defaultCloneOptions) {
7857
7857
  if (!descriptor)
7858
7858
  continue;
7859
7859
  const cloned = clone(val[k22], seen, options);
7860
- if ("get" in descriptor) {
7860
+ if (options.forceWritable) {
7861
+ Object.defineProperty(out, k22, {
7862
+ enumerable: descriptor.enumerable,
7863
+ configurable: true,
7864
+ writable: true,
7865
+ value: cloned
7866
+ });
7867
+ } else if ("get" in descriptor) {
7861
7868
  Object.defineProperty(out, k22, {
7862
7869
  ...descriptor,
7863
7870
  get() {
@@ -7867,7 +7874,6 @@ function clone(val, seen, options = defaultCloneOptions) {
7867
7874
  } else {
7868
7875
  Object.defineProperty(out, k22, {
7869
7876
  ...descriptor,
7870
- writable: options.forceWritable ? true : descriptor.writable,
7871
7877
  value: cloned
7872
7878
  });
7873
7879
  }
@@ -8029,7 +8035,7 @@ function objDisplay(obj, options = {}) {
8029
8035
  if (options.truncate && str.length >= options.truncate) {
8030
8036
  if (type2 === "[object Function]") {
8031
8037
  const fn2 = obj;
8032
- return !fn2.name || fn2.name === "" ? "[Function]" : `[Function: ${fn2.name}]`;
8038
+ return !fn2.name ? "[Function]" : `[Function: ${fn2.name}]`;
8033
8039
  } else if (type2 === "[object Array]") {
8034
8040
  return `[ Array(${obj.length}) ]`;
8035
8041
  } else if (type2 === "[object Object]") {
@@ -8469,6 +8475,7 @@ function joinAlignedDiffsExpand(diffs, options) {
8469
8475
  }
8470
8476
  var noColor = (string3) => string3;
8471
8477
  var DIFF_CONTEXT_DEFAULT = 5;
8478
+ var DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
8472
8479
  function getDefaultOptions() {
8473
8480
  const c2 = getColors();
8474
8481
  return {
@@ -8489,7 +8496,10 @@ function getDefaultOptions() {
8489
8496
  expand: true,
8490
8497
  includeChangeCounts: false,
8491
8498
  omitAnnotationLines: false,
8492
- patchColor: c2.yellow
8499
+ patchColor: c2.yellow,
8500
+ truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
8501
+ truncateAnnotation: "... Diff result is truncated",
8502
+ truncateAnnotationColor: noColor
8493
8503
  };
8494
8504
  }
8495
8505
  function getCompareKeys(compareKeys) {
@@ -8557,16 +8567,21 @@ ${bColor(b2)}
8557
8567
 
8558
8568
  `;
8559
8569
  }
8560
- function printDiffLines(diffs, options) {
8561
- return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options));
8570
+ function printDiffLines(diffs, truncated, options) {
8571
+ return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options)) + (truncated ? options.truncateAnnotationColor(`
8572
+ ${options.truncateAnnotation}`) : "");
8562
8573
  }
8563
8574
  function diffLinesUnified(aLines, bLines, options) {
8575
+ const normalizedOptions = normalizeDiffOptions(options);
8576
+ const [diffs, truncated] = diffLinesRaw(
8577
+ isEmptyString(aLines) ? [] : aLines,
8578
+ isEmptyString(bLines) ? [] : bLines,
8579
+ normalizedOptions
8580
+ );
8564
8581
  return printDiffLines(
8565
- diffLinesRaw(
8566
- isEmptyString(aLines) ? [] : aLines,
8567
- isEmptyString(bLines) ? [] : bLines
8568
- ),
8569
- normalizeDiffOptions(options)
8582
+ diffs,
8583
+ truncated,
8584
+ normalizedOptions
8570
8585
  );
8571
8586
  }
8572
8587
  function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options) {
@@ -8581,7 +8596,7 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
8581
8596
  if (aLinesDisplay.length !== aLinesCompare.length || bLinesDisplay.length !== bLinesCompare.length) {
8582
8597
  return diffLinesUnified(aLinesDisplay, bLinesDisplay, options);
8583
8598
  }
8584
- const diffs = diffLinesRaw(aLinesCompare, bLinesCompare);
8599
+ const [diffs, truncated] = diffLinesRaw(aLinesCompare, bLinesCompare, options);
8585
8600
  let aIndex = 0;
8586
8601
  let bIndex = 0;
8587
8602
  diffs.forEach((diff2) => {
@@ -8600,11 +8615,14 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
8600
8615
  bIndex += 1;
8601
8616
  }
8602
8617
  });
8603
- return printDiffLines(diffs, normalizeDiffOptions(options));
8604
- }
8605
- function diffLinesRaw(aLines, bLines) {
8606
- const aLength = aLines.length;
8607
- const bLength = bLines.length;
8618
+ return printDiffLines(diffs, truncated, normalizeDiffOptions(options));
8619
+ }
8620
+ function diffLinesRaw(aLines, bLines, options) {
8621
+ const truncate2 = (options == null ? void 0 : options.truncateThreshold) ?? false;
8622
+ const truncateThreshold = Math.max(Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0), 0);
8623
+ const aLength = truncate2 ? Math.min(aLines.length, truncateThreshold) : aLines.length;
8624
+ const bLength = truncate2 ? Math.min(bLines.length, truncateThreshold) : bLines.length;
8625
+ const truncated = aLength !== aLines.length || bLength !== bLines.length;
8608
8626
  const isCommon = (aIndex2, bIndex2) => aLines[aIndex2] === bLines[bIndex2];
8609
8627
  const diffs = [];
8610
8628
  let aIndex = 0;
@@ -8623,7 +8641,7 @@ function diffLinesRaw(aLines, bLines) {
8623
8641
  diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
8624
8642
  for (; bIndex !== bLength; bIndex += 1)
8625
8643
  diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
8626
- return diffs;
8644
+ return [diffs, truncated];
8627
8645
  }
8628
8646
  function getCommonMessage(message, options) {
8629
8647
  const { commonColor } = normalizeDiffOptions(options);
@@ -9813,10 +9831,10 @@ function createSuiteCollector(name, factory = () => {
9813
9831
  }
9814
9832
  if (runner.config.includeTaskLocation) {
9815
9833
  const limit = Error.stackTraceLimit;
9816
- Error.stackTraceLimit = 10;
9834
+ Error.stackTraceLimit = 15;
9817
9835
  const error = new Error("stacktrace").stack;
9818
9836
  Error.stackTraceLimit = limit;
9819
- const stack = findStackTrace(error, task2.each ?? false);
9837
+ const stack = findTestFileStackTrace(error, task2.each ?? false);
9820
9838
  if (stack)
9821
9839
  task2.location = stack;
9822
9840
  }
@@ -9869,18 +9887,12 @@ function createSuiteCollector(name, factory = () => {
9869
9887
  };
9870
9888
  if (runner && includeLocation && runner.config.includeTaskLocation) {
9871
9889
  const limit = Error.stackTraceLimit;
9872
- Error.stackTraceLimit = 5;
9890
+ Error.stackTraceLimit = 15;
9873
9891
  const error = new Error("stacktrace").stack;
9874
9892
  Error.stackTraceLimit = limit;
9875
- const stack = parseSingleStack(error.split("\n")[5]);
9876
- if (stack) {
9877
- suite2.location = {
9878
- line: stack.line,
9879
- // because source map is boundary based, this line leads to ")" in test.each()[(]),
9880
- // but it should be the next opening bracket - here we assume it's on the same line
9881
- column: each ? stack.column + 1 : stack.column
9882
- };
9883
- }
9893
+ const stack = findTestFileStackTrace(error, suite2.each ?? false);
9894
+ if (stack)
9895
+ suite2.location = stack;
9884
9896
  }
9885
9897
  setHooks(suite2, createSuiteHooks());
9886
9898
  }
@@ -10024,8 +10036,8 @@ function formatTemplateString(cases, args) {
10024
10036
  }
10025
10037
  return res;
10026
10038
  }
10027
- function findStackTrace(error, each) {
10028
- const lines = error.split("\n").slice(4);
10039
+ function findTestFileStackTrace(error, each) {
10040
+ const lines = error.split("\n").slice(1);
10029
10041
  for (const line of lines) {
10030
10042
  const stack = parseSingleStack(line);
10031
10043
  if (stack && stack.file === getTestFilepath()) {
@@ -10164,7 +10176,7 @@ function isFirstRun() {
10164
10176
  return firstRun;
10165
10177
  }
10166
10178
 
10167
- // ../../node_modules/vitest/dist/vendor/vi.JYQecGiw.js
10179
+ // ../../node_modules/vitest/dist/vendor/vi.Y_w82WR8.js
10168
10180
  init_cjs_shims();
10169
10181
 
10170
10182
  // ../../node_modules/chai/index.mjs
@@ -10692,7 +10704,7 @@ function iterableEquality(a, b2, customTesters = [], aStack = [], bStack = []) {
10692
10704
  return iterableEquality(
10693
10705
  a2,
10694
10706
  b22,
10695
- [...filteredCustomTesters],
10707
+ [...customTesters],
10696
10708
  [...aStack],
10697
10709
  [...bStack]
10698
10710
  );
@@ -10770,7 +10782,7 @@ function subsetEquality(object2, subset, customTesters = []) {
10770
10782
  if (!isObjectWithKeys(subset2))
10771
10783
  return void 0;
10772
10784
  return Object.keys(subset2).every((key) => {
10773
- if (isObjectWithKeys(subset2[key])) {
10785
+ if (typeof subset2[key] === "object") {
10774
10786
  if (seenReferences.has(subset2[key]))
10775
10787
  return equals(object22[key], subset2[key], filteredCustomTesters);
10776
10788
  seenReferences.set(subset2[key], true);
@@ -10834,6 +10846,57 @@ Received: serializes to the same string
10834
10846
  function pluralize(word, count) {
10835
10847
  return `${count} ${word}${count === 1 ? "" : "s"}`;
10836
10848
  }
10849
+ function getObjectKeys(object2) {
10850
+ return [
10851
+ ...Object.keys(object2),
10852
+ ...Object.getOwnPropertySymbols(object2).filter(
10853
+ (s) => {
10854
+ var _a2;
10855
+ return (_a2 = Object.getOwnPropertyDescriptor(object2, s)) == null ? void 0 : _a2.enumerable;
10856
+ }
10857
+ )
10858
+ ];
10859
+ }
10860
+ function getObjectSubset(object2, subset, customTesters = []) {
10861
+ let stripped = 0;
10862
+ const getObjectSubsetWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object22, subset2) => {
10863
+ if (Array.isArray(object22)) {
10864
+ if (Array.isArray(subset2) && subset2.length === object22.length) {
10865
+ return subset2.map(
10866
+ (sub, i2) => getObjectSubsetWithContext(seenReferences)(object22[i2], sub)
10867
+ );
10868
+ }
10869
+ } else if (object22 instanceof Date) {
10870
+ return object22;
10871
+ } else if (isObject(object22) && isObject(subset2)) {
10872
+ if (equals(object22, subset2, [
10873
+ ...customTesters,
10874
+ iterableEquality,
10875
+ subsetEquality
10876
+ ])) {
10877
+ return subset2;
10878
+ }
10879
+ const trimmed = {};
10880
+ seenReferences.set(object22, trimmed);
10881
+ for (const key of getObjectKeys(object22)) {
10882
+ if (hasPropertyInObject(subset2, key)) {
10883
+ trimmed[key] = seenReferences.has(object22[key]) ? seenReferences.get(object22[key]) : getObjectSubsetWithContext(seenReferences)(object22[key], subset2[key]);
10884
+ } else {
10885
+ if (!seenReferences.has(object22[key])) {
10886
+ stripped += 1;
10887
+ if (isObject(object22[key]))
10888
+ stripped += getObjectKeys(object22[key]).length;
10889
+ getObjectSubsetWithContext(seenReferences)(object22[key], subset2[key]);
10890
+ }
10891
+ }
10892
+ }
10893
+ if (getObjectKeys(trimmed).length > 0)
10894
+ return trimmed;
10895
+ }
10896
+ return object22;
10897
+ };
10898
+ return { subset: getObjectSubsetWithContext()(object2, subset), stripped };
10899
+ }
10837
10900
  var AsymmetricMatcher3 = class {
10838
10901
  constructor(sample, inverse = false) {
10839
10902
  this.sample = sample;
@@ -11261,16 +11324,30 @@ var JestChaiExpect = (chai3, utils) => {
11261
11324
  });
11262
11325
  def("toMatchObject", function(expected) {
11263
11326
  const actual = this._obj;
11264
- return this.assert(
11265
- equals(actual, expected, [...customTesters, iterableEquality, subsetEquality]),
11266
- "expected #{this} to match object #{exp}",
11267
- "expected #{this} to not match object #{exp}",
11268
- expected,
11269
- actual
11270
- );
11327
+ const pass = equals(actual, expected, [...customTesters, iterableEquality, subsetEquality]);
11328
+ const isNot = utils.flag(this, "negate");
11329
+ const { subset: actualSubset, stripped } = getObjectSubset(actual, expected);
11330
+ if (pass && isNot || !pass && !isNot) {
11331
+ const msg = utils.getMessage(
11332
+ this,
11333
+ [
11334
+ pass,
11335
+ "expected #{this} to match object #{exp}",
11336
+ "expected #{this} to not match object #{exp}",
11337
+ expected,
11338
+ actualSubset,
11339
+ false
11340
+ ]
11341
+ );
11342
+ const message = stripped === 0 ? msg : `${msg}
11343
+ (${stripped} matching ${stripped === 1 ? "property" : "properties"} omitted from actual)`;
11344
+ throw new AssertionError2(message, { showDiff: true, expected, actual: actualSubset });
11345
+ }
11271
11346
  });
11272
11347
  def("toMatch", function(expected) {
11273
11348
  const actual = this._obj;
11349
+ if (typeof actual !== "string")
11350
+ throw new TypeError(`.toMatch() expects to receive a string, but got ${typeof actual}`);
11274
11351
  return this.assert(
11275
11352
  typeof expected === "string" ? actual.includes(expected) : actual.match(expected),
11276
11353
  `expected #{this} to match #{exp}`,
@@ -11612,12 +11689,15 @@ Number of calls: ${c2().bold(spy.mock.calls.length)}
11612
11689
  const spy = getSpy(this);
11613
11690
  const spyName = spy.getMockName();
11614
11691
  const nthCall = spy.mock.calls[times - 1];
11692
+ const callCount = spy.mock.calls.length;
11693
+ const isCalled = times <= callCount;
11615
11694
  this.assert(
11616
11695
  equals(nthCall, args, [...customTesters, iterableEquality]),
11617
- `expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,
11696
+ `expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}${isCalled ? `` : `, but called only ${callCount} times`}`,
11618
11697
  `expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,
11619
11698
  args,
11620
- nthCall
11699
+ nthCall,
11700
+ isCalled
11621
11701
  );
11622
11702
  });
11623
11703
  def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
@@ -13388,7 +13468,7 @@ function resetDate() {
13388
13468
  globalThis.Date = RealDate;
13389
13469
  }
13390
13470
 
13391
- // ../../node_modules/vitest/dist/vendor/vi.JYQecGiw.js
13471
+ // ../../node_modules/vitest/dist/vendor/vi.Y_w82WR8.js
13392
13472
  function resetModules(modules, resetMocks = false) {
13393
13473
  const skipPaths = [
13394
13474
  // Vitest
@@ -15513,12 +15593,14 @@ function createVitest() {
15513
15593
  let _mockedDate = null;
15514
15594
  let _config = null;
15515
15595
  const workerState = getWorkerState();
15516
- const _timers = new FakeTimers({
15596
+ let _timers;
15597
+ const timers = () => _timers || (_timers = new FakeTimers({
15517
15598
  global: globalThis,
15518
15599
  config: workerState.config.fakeTimers
15519
- });
15600
+ }));
15520
15601
  const _stubsGlobal = /* @__PURE__ */ new Map();
15521
15602
  const _stubsEnv = /* @__PURE__ */ new Map();
15603
+ const _envBooleans = ["PROD", "DEV", "SSR"];
15522
15604
  const getImporter = () => {
15523
15605
  const stackTrace = createSimpleStackTrace({ stackTraceLimit: 4 });
15524
15606
  const importerStack = stackTrace.split("\n")[4];
@@ -15536,73 +15618,73 @@ function createVitest() {
15536
15618
  }
15537
15619
  }
15538
15620
  if (config2)
15539
- _timers.configure({ ...workerState.config.fakeTimers, ...config2 });
15621
+ timers().configure({ ...workerState.config.fakeTimers, ...config2 });
15540
15622
  else
15541
- _timers.configure(workerState.config.fakeTimers);
15542
- _timers.useFakeTimers();
15623
+ timers().configure(workerState.config.fakeTimers);
15624
+ timers().useFakeTimers();
15543
15625
  return utils;
15544
15626
  },
15545
15627
  isFakeTimers() {
15546
- return _timers.isFakeTimers();
15628
+ return timers().isFakeTimers();
15547
15629
  },
15548
15630
  useRealTimers() {
15549
- _timers.useRealTimers();
15631
+ timers().useRealTimers();
15550
15632
  _mockedDate = null;
15551
15633
  return utils;
15552
15634
  },
15553
15635
  runOnlyPendingTimers() {
15554
- _timers.runOnlyPendingTimers();
15636
+ timers().runOnlyPendingTimers();
15555
15637
  return utils;
15556
15638
  },
15557
15639
  async runOnlyPendingTimersAsync() {
15558
- await _timers.runOnlyPendingTimersAsync();
15640
+ await timers().runOnlyPendingTimersAsync();
15559
15641
  return utils;
15560
15642
  },
15561
15643
  runAllTimers() {
15562
- _timers.runAllTimers();
15644
+ timers().runAllTimers();
15563
15645
  return utils;
15564
15646
  },
15565
15647
  async runAllTimersAsync() {
15566
- await _timers.runAllTimersAsync();
15648
+ await timers().runAllTimersAsync();
15567
15649
  return utils;
15568
15650
  },
15569
15651
  runAllTicks() {
15570
- _timers.runAllTicks();
15652
+ timers().runAllTicks();
15571
15653
  return utils;
15572
15654
  },
15573
15655
  advanceTimersByTime(ms) {
15574
- _timers.advanceTimersByTime(ms);
15656
+ timers().advanceTimersByTime(ms);
15575
15657
  return utils;
15576
15658
  },
15577
15659
  async advanceTimersByTimeAsync(ms) {
15578
- await _timers.advanceTimersByTimeAsync(ms);
15660
+ await timers().advanceTimersByTimeAsync(ms);
15579
15661
  return utils;
15580
15662
  },
15581
15663
  advanceTimersToNextTimer() {
15582
- _timers.advanceTimersToNextTimer();
15664
+ timers().advanceTimersToNextTimer();
15583
15665
  return utils;
15584
15666
  },
15585
15667
  async advanceTimersToNextTimerAsync() {
15586
- await _timers.advanceTimersToNextTimerAsync();
15668
+ await timers().advanceTimersToNextTimerAsync();
15587
15669
  return utils;
15588
15670
  },
15589
15671
  getTimerCount() {
15590
- return _timers.getTimerCount();
15672
+ return timers().getTimerCount();
15591
15673
  },
15592
15674
  setSystemTime(time) {
15593
15675
  const date = time instanceof Date ? time : new Date(time);
15594
15676
  _mockedDate = date;
15595
- _timers.setSystemTime(date);
15677
+ timers().setSystemTime(date);
15596
15678
  return utils;
15597
15679
  },
15598
15680
  getMockedSystemTime() {
15599
15681
  return _mockedDate;
15600
15682
  },
15601
15683
  getRealSystemTime() {
15602
- return _timers.getRealSystemTime();
15684
+ return timers().getRealSystemTime();
15603
15685
  },
15604
15686
  clearAllTimers() {
15605
- _timers.clearAllTimers();
15687
+ timers().clearAllTimers();
15606
15688
  return utils;
15607
15689
  },
15608
15690
  // mocks
@@ -15681,7 +15763,10 @@ function createVitest() {
15681
15763
  stubEnv(name, value) {
15682
15764
  if (!_stubsEnv.has(name))
15683
15765
  _stubsEnv.set(name, process.env[name]);
15684
- process.env[name] = value;
15766
+ if (_envBooleans.includes(name))
15767
+ process.env[name] = value ? "1" : "";
15768
+ else
15769
+ process.env[name] = String(value);
15685
15770
  return utils;
15686
15771
  },
15687
15772
  unstubAllGlobals() {
@@ -15726,7 +15811,7 @@ function createVitest() {
15726
15811
  var vitest = createVitest();
15727
15812
  var vi = vitest;
15728
15813
 
15729
- // ../../node_modules/vitest/dist/vendor/index.BeX1oZht.js
15814
+ // ../../node_modules/vitest/dist/vendor/index.0RrMQKD8.js
15730
15815
  init_cjs_shims();
15731
15816
  function getRunningMode() {
15732
15817
  return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";