@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.
@@ -7783,7 +7783,14 @@ function clone(val, seen, options = defaultCloneOptions) {
7783
7783
  if (!descriptor)
7784
7784
  continue;
7785
7785
  const cloned = clone(val[k22], seen, options);
7786
- if ("get" in descriptor) {
7786
+ if (options.forceWritable) {
7787
+ Object.defineProperty(out, k22, {
7788
+ enumerable: descriptor.enumerable,
7789
+ configurable: true,
7790
+ writable: true,
7791
+ value: cloned
7792
+ });
7793
+ } else if ("get" in descriptor) {
7787
7794
  Object.defineProperty(out, k22, {
7788
7795
  ...descriptor,
7789
7796
  get() {
@@ -7793,7 +7800,6 @@ function clone(val, seen, options = defaultCloneOptions) {
7793
7800
  } else {
7794
7801
  Object.defineProperty(out, k22, {
7795
7802
  ...descriptor,
7796
- writable: options.forceWritable ? true : descriptor.writable,
7797
7803
  value: cloned
7798
7804
  });
7799
7805
  }
@@ -7955,7 +7961,7 @@ function objDisplay(obj, options = {}) {
7955
7961
  if (options.truncate && str.length >= options.truncate) {
7956
7962
  if (type2 === "[object Function]") {
7957
7963
  const fn2 = obj;
7958
- return !fn2.name || fn2.name === "" ? "[Function]" : `[Function: ${fn2.name}]`;
7964
+ return !fn2.name ? "[Function]" : `[Function: ${fn2.name}]`;
7959
7965
  } else if (type2 === "[object Array]") {
7960
7966
  return `[ Array(${obj.length}) ]`;
7961
7967
  } else if (type2 === "[object Object]") {
@@ -8395,6 +8401,7 @@ function joinAlignedDiffsExpand(diffs, options) {
8395
8401
  }
8396
8402
  var noColor = (string3) => string3;
8397
8403
  var DIFF_CONTEXT_DEFAULT = 5;
8404
+ var DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
8398
8405
  function getDefaultOptions() {
8399
8406
  const c2 = getColors();
8400
8407
  return {
@@ -8415,7 +8422,10 @@ function getDefaultOptions() {
8415
8422
  expand: true,
8416
8423
  includeChangeCounts: false,
8417
8424
  omitAnnotationLines: false,
8418
- patchColor: c2.yellow
8425
+ patchColor: c2.yellow,
8426
+ truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
8427
+ truncateAnnotation: "... Diff result is truncated",
8428
+ truncateAnnotationColor: noColor
8419
8429
  };
8420
8430
  }
8421
8431
  function getCompareKeys(compareKeys) {
@@ -8483,16 +8493,21 @@ ${bColor(b2)}
8483
8493
 
8484
8494
  `;
8485
8495
  }
8486
- function printDiffLines(diffs, options) {
8487
- return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options));
8496
+ function printDiffLines(diffs, truncated, options) {
8497
+ return printAnnotation(options, countChanges(diffs)) + (options.expand ? joinAlignedDiffsExpand(diffs, options) : joinAlignedDiffsNoExpand(diffs, options)) + (truncated ? options.truncateAnnotationColor(`
8498
+ ${options.truncateAnnotation}`) : "");
8488
8499
  }
8489
8500
  function diffLinesUnified(aLines, bLines, options) {
8501
+ const normalizedOptions = normalizeDiffOptions(options);
8502
+ const [diffs, truncated] = diffLinesRaw(
8503
+ isEmptyString(aLines) ? [] : aLines,
8504
+ isEmptyString(bLines) ? [] : bLines,
8505
+ normalizedOptions
8506
+ );
8490
8507
  return printDiffLines(
8491
- diffLinesRaw(
8492
- isEmptyString(aLines) ? [] : aLines,
8493
- isEmptyString(bLines) ? [] : bLines
8494
- ),
8495
- normalizeDiffOptions(options)
8508
+ diffs,
8509
+ truncated,
8510
+ normalizedOptions
8496
8511
  );
8497
8512
  }
8498
8513
  function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options) {
@@ -8507,7 +8522,7 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
8507
8522
  if (aLinesDisplay.length !== aLinesCompare.length || bLinesDisplay.length !== bLinesCompare.length) {
8508
8523
  return diffLinesUnified(aLinesDisplay, bLinesDisplay, options);
8509
8524
  }
8510
- const diffs = diffLinesRaw(aLinesCompare, bLinesCompare);
8525
+ const [diffs, truncated] = diffLinesRaw(aLinesCompare, bLinesCompare, options);
8511
8526
  let aIndex = 0;
8512
8527
  let bIndex = 0;
8513
8528
  diffs.forEach((diff2) => {
@@ -8526,11 +8541,14 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
8526
8541
  bIndex += 1;
8527
8542
  }
8528
8543
  });
8529
- return printDiffLines(diffs, normalizeDiffOptions(options));
8530
- }
8531
- function diffLinesRaw(aLines, bLines) {
8532
- const aLength = aLines.length;
8533
- const bLength = bLines.length;
8544
+ return printDiffLines(diffs, truncated, normalizeDiffOptions(options));
8545
+ }
8546
+ function diffLinesRaw(aLines, bLines, options) {
8547
+ const truncate2 = (options == null ? void 0 : options.truncateThreshold) ?? false;
8548
+ const truncateThreshold = Math.max(Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0), 0);
8549
+ const aLength = truncate2 ? Math.min(aLines.length, truncateThreshold) : aLines.length;
8550
+ const bLength = truncate2 ? Math.min(bLines.length, truncateThreshold) : bLines.length;
8551
+ const truncated = aLength !== aLines.length || bLength !== bLines.length;
8534
8552
  const isCommon = (aIndex2, bIndex2) => aLines[aIndex2] === bLines[bIndex2];
8535
8553
  const diffs = [];
8536
8554
  let aIndex = 0;
@@ -8549,7 +8567,7 @@ function diffLinesRaw(aLines, bLines) {
8549
8567
  diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));
8550
8568
  for (; bIndex !== bLength; bIndex += 1)
8551
8569
  diffs.push(new Diff(DIFF_INSERT, bLines[bIndex]));
8552
- return diffs;
8570
+ return [diffs, truncated];
8553
8571
  }
8554
8572
  function getCommonMessage(message, options) {
8555
8573
  const { commonColor } = normalizeDiffOptions(options);
@@ -9739,10 +9757,10 @@ function createSuiteCollector(name, factory = () => {
9739
9757
  }
9740
9758
  if (runner.config.includeTaskLocation) {
9741
9759
  const limit = Error.stackTraceLimit;
9742
- Error.stackTraceLimit = 10;
9760
+ Error.stackTraceLimit = 15;
9743
9761
  const error = new Error("stacktrace").stack;
9744
9762
  Error.stackTraceLimit = limit;
9745
- const stack = findStackTrace(error, task2.each ?? false);
9763
+ const stack = findTestFileStackTrace(error, task2.each ?? false);
9746
9764
  if (stack)
9747
9765
  task2.location = stack;
9748
9766
  }
@@ -9795,18 +9813,12 @@ function createSuiteCollector(name, factory = () => {
9795
9813
  };
9796
9814
  if (runner && includeLocation && runner.config.includeTaskLocation) {
9797
9815
  const limit = Error.stackTraceLimit;
9798
- Error.stackTraceLimit = 5;
9816
+ Error.stackTraceLimit = 15;
9799
9817
  const error = new Error("stacktrace").stack;
9800
9818
  Error.stackTraceLimit = limit;
9801
- const stack = parseSingleStack(error.split("\n")[5]);
9802
- if (stack) {
9803
- suite2.location = {
9804
- line: stack.line,
9805
- // because source map is boundary based, this line leads to ")" in test.each()[(]),
9806
- // but it should be the next opening bracket - here we assume it's on the same line
9807
- column: each ? stack.column + 1 : stack.column
9808
- };
9809
- }
9819
+ const stack = findTestFileStackTrace(error, suite2.each ?? false);
9820
+ if (stack)
9821
+ suite2.location = stack;
9810
9822
  }
9811
9823
  setHooks(suite2, createSuiteHooks());
9812
9824
  }
@@ -9950,8 +9962,8 @@ function formatTemplateString(cases, args) {
9950
9962
  }
9951
9963
  return res;
9952
9964
  }
9953
- function findStackTrace(error, each) {
9954
- const lines = error.split("\n").slice(4);
9965
+ function findTestFileStackTrace(error, each) {
9966
+ const lines = error.split("\n").slice(1);
9955
9967
  for (const line of lines) {
9956
9968
  const stack = parseSingleStack(line);
9957
9969
  if (stack && stack.file === getTestFilepath()) {
@@ -10090,7 +10102,7 @@ function isFirstRun() {
10090
10102
  return firstRun;
10091
10103
  }
10092
10104
 
10093
- // ../../node_modules/vitest/dist/vendor/vi.JYQecGiw.js
10105
+ // ../../node_modules/vitest/dist/vendor/vi.Y_w82WR8.js
10094
10106
  init_esm_shims();
10095
10107
 
10096
10108
  // ../../node_modules/chai/index.mjs
@@ -10618,7 +10630,7 @@ function iterableEquality(a, b2, customTesters = [], aStack = [], bStack = []) {
10618
10630
  return iterableEquality(
10619
10631
  a2,
10620
10632
  b22,
10621
- [...filteredCustomTesters],
10633
+ [...customTesters],
10622
10634
  [...aStack],
10623
10635
  [...bStack]
10624
10636
  );
@@ -10696,7 +10708,7 @@ function subsetEquality(object2, subset, customTesters = []) {
10696
10708
  if (!isObjectWithKeys(subset2))
10697
10709
  return void 0;
10698
10710
  return Object.keys(subset2).every((key) => {
10699
- if (isObjectWithKeys(subset2[key])) {
10711
+ if (typeof subset2[key] === "object") {
10700
10712
  if (seenReferences.has(subset2[key]))
10701
10713
  return equals(object22[key], subset2[key], filteredCustomTesters);
10702
10714
  seenReferences.set(subset2[key], true);
@@ -10760,6 +10772,57 @@ Received: serializes to the same string
10760
10772
  function pluralize(word, count) {
10761
10773
  return `${count} ${word}${count === 1 ? "" : "s"}`;
10762
10774
  }
10775
+ function getObjectKeys(object2) {
10776
+ return [
10777
+ ...Object.keys(object2),
10778
+ ...Object.getOwnPropertySymbols(object2).filter(
10779
+ (s) => {
10780
+ var _a2;
10781
+ return (_a2 = Object.getOwnPropertyDescriptor(object2, s)) == null ? void 0 : _a2.enumerable;
10782
+ }
10783
+ )
10784
+ ];
10785
+ }
10786
+ function getObjectSubset(object2, subset, customTesters = []) {
10787
+ let stripped = 0;
10788
+ const getObjectSubsetWithContext = (seenReferences = /* @__PURE__ */ new WeakMap()) => (object22, subset2) => {
10789
+ if (Array.isArray(object22)) {
10790
+ if (Array.isArray(subset2) && subset2.length === object22.length) {
10791
+ return subset2.map(
10792
+ (sub, i2) => getObjectSubsetWithContext(seenReferences)(object22[i2], sub)
10793
+ );
10794
+ }
10795
+ } else if (object22 instanceof Date) {
10796
+ return object22;
10797
+ } else if (isObject(object22) && isObject(subset2)) {
10798
+ if (equals(object22, subset2, [
10799
+ ...customTesters,
10800
+ iterableEquality,
10801
+ subsetEquality
10802
+ ])) {
10803
+ return subset2;
10804
+ }
10805
+ const trimmed = {};
10806
+ seenReferences.set(object22, trimmed);
10807
+ for (const key of getObjectKeys(object22)) {
10808
+ if (hasPropertyInObject(subset2, key)) {
10809
+ trimmed[key] = seenReferences.has(object22[key]) ? seenReferences.get(object22[key]) : getObjectSubsetWithContext(seenReferences)(object22[key], subset2[key]);
10810
+ } else {
10811
+ if (!seenReferences.has(object22[key])) {
10812
+ stripped += 1;
10813
+ if (isObject(object22[key]))
10814
+ stripped += getObjectKeys(object22[key]).length;
10815
+ getObjectSubsetWithContext(seenReferences)(object22[key], subset2[key]);
10816
+ }
10817
+ }
10818
+ }
10819
+ if (getObjectKeys(trimmed).length > 0)
10820
+ return trimmed;
10821
+ }
10822
+ return object22;
10823
+ };
10824
+ return { subset: getObjectSubsetWithContext()(object2, subset), stripped };
10825
+ }
10763
10826
  var AsymmetricMatcher3 = class {
10764
10827
  constructor(sample, inverse = false) {
10765
10828
  this.sample = sample;
@@ -11187,16 +11250,30 @@ var JestChaiExpect = (chai3, utils) => {
11187
11250
  });
11188
11251
  def("toMatchObject", function(expected) {
11189
11252
  const actual = this._obj;
11190
- return this.assert(
11191
- equals(actual, expected, [...customTesters, iterableEquality, subsetEquality]),
11192
- "expected #{this} to match object #{exp}",
11193
- "expected #{this} to not match object #{exp}",
11194
- expected,
11195
- actual
11196
- );
11253
+ const pass = equals(actual, expected, [...customTesters, iterableEquality, subsetEquality]);
11254
+ const isNot = utils.flag(this, "negate");
11255
+ const { subset: actualSubset, stripped } = getObjectSubset(actual, expected);
11256
+ if (pass && isNot || !pass && !isNot) {
11257
+ const msg = utils.getMessage(
11258
+ this,
11259
+ [
11260
+ pass,
11261
+ "expected #{this} to match object #{exp}",
11262
+ "expected #{this} to not match object #{exp}",
11263
+ expected,
11264
+ actualSubset,
11265
+ false
11266
+ ]
11267
+ );
11268
+ const message = stripped === 0 ? msg : `${msg}
11269
+ (${stripped} matching ${stripped === 1 ? "property" : "properties"} omitted from actual)`;
11270
+ throw new AssertionError2(message, { showDiff: true, expected, actual: actualSubset });
11271
+ }
11197
11272
  });
11198
11273
  def("toMatch", function(expected) {
11199
11274
  const actual = this._obj;
11275
+ if (typeof actual !== "string")
11276
+ throw new TypeError(`.toMatch() expects to receive a string, but got ${typeof actual}`);
11200
11277
  return this.assert(
11201
11278
  typeof expected === "string" ? actual.includes(expected) : actual.match(expected),
11202
11279
  `expected #{this} to match #{exp}`,
@@ -11538,12 +11615,15 @@ Number of calls: ${c2().bold(spy.mock.calls.length)}
11538
11615
  const spy = getSpy(this);
11539
11616
  const spyName = spy.getMockName();
11540
11617
  const nthCall = spy.mock.calls[times - 1];
11618
+ const callCount = spy.mock.calls.length;
11619
+ const isCalled = times <= callCount;
11541
11620
  this.assert(
11542
11621
  equals(nthCall, args, [...customTesters, iterableEquality]),
11543
- `expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}`,
11622
+ `expected ${ordinalOf(times)} "${spyName}" call to have been called with #{exp}${isCalled ? `` : `, but called only ${callCount} times`}`,
11544
11623
  `expected ${ordinalOf(times)} "${spyName}" call to not have been called with #{exp}`,
11545
11624
  args,
11546
- nthCall
11625
+ nthCall,
11626
+ isCalled
11547
11627
  );
11548
11628
  });
11549
11629
  def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
@@ -13314,7 +13394,7 @@ function resetDate() {
13314
13394
  globalThis.Date = RealDate;
13315
13395
  }
13316
13396
 
13317
- // ../../node_modules/vitest/dist/vendor/vi.JYQecGiw.js
13397
+ // ../../node_modules/vitest/dist/vendor/vi.Y_w82WR8.js
13318
13398
  function resetModules(modules, resetMocks = false) {
13319
13399
  const skipPaths = [
13320
13400
  // Vitest
@@ -15439,12 +15519,14 @@ function createVitest() {
15439
15519
  let _mockedDate = null;
15440
15520
  let _config = null;
15441
15521
  const workerState = getWorkerState();
15442
- const _timers = new FakeTimers({
15522
+ let _timers;
15523
+ const timers = () => _timers || (_timers = new FakeTimers({
15443
15524
  global: globalThis,
15444
15525
  config: workerState.config.fakeTimers
15445
- });
15526
+ }));
15446
15527
  const _stubsGlobal = /* @__PURE__ */ new Map();
15447
15528
  const _stubsEnv = /* @__PURE__ */ new Map();
15529
+ const _envBooleans = ["PROD", "DEV", "SSR"];
15448
15530
  const getImporter = () => {
15449
15531
  const stackTrace = createSimpleStackTrace({ stackTraceLimit: 4 });
15450
15532
  const importerStack = stackTrace.split("\n")[4];
@@ -15462,73 +15544,73 @@ function createVitest() {
15462
15544
  }
15463
15545
  }
15464
15546
  if (config2)
15465
- _timers.configure({ ...workerState.config.fakeTimers, ...config2 });
15547
+ timers().configure({ ...workerState.config.fakeTimers, ...config2 });
15466
15548
  else
15467
- _timers.configure(workerState.config.fakeTimers);
15468
- _timers.useFakeTimers();
15549
+ timers().configure(workerState.config.fakeTimers);
15550
+ timers().useFakeTimers();
15469
15551
  return utils;
15470
15552
  },
15471
15553
  isFakeTimers() {
15472
- return _timers.isFakeTimers();
15554
+ return timers().isFakeTimers();
15473
15555
  },
15474
15556
  useRealTimers() {
15475
- _timers.useRealTimers();
15557
+ timers().useRealTimers();
15476
15558
  _mockedDate = null;
15477
15559
  return utils;
15478
15560
  },
15479
15561
  runOnlyPendingTimers() {
15480
- _timers.runOnlyPendingTimers();
15562
+ timers().runOnlyPendingTimers();
15481
15563
  return utils;
15482
15564
  },
15483
15565
  async runOnlyPendingTimersAsync() {
15484
- await _timers.runOnlyPendingTimersAsync();
15566
+ await timers().runOnlyPendingTimersAsync();
15485
15567
  return utils;
15486
15568
  },
15487
15569
  runAllTimers() {
15488
- _timers.runAllTimers();
15570
+ timers().runAllTimers();
15489
15571
  return utils;
15490
15572
  },
15491
15573
  async runAllTimersAsync() {
15492
- await _timers.runAllTimersAsync();
15574
+ await timers().runAllTimersAsync();
15493
15575
  return utils;
15494
15576
  },
15495
15577
  runAllTicks() {
15496
- _timers.runAllTicks();
15578
+ timers().runAllTicks();
15497
15579
  return utils;
15498
15580
  },
15499
15581
  advanceTimersByTime(ms) {
15500
- _timers.advanceTimersByTime(ms);
15582
+ timers().advanceTimersByTime(ms);
15501
15583
  return utils;
15502
15584
  },
15503
15585
  async advanceTimersByTimeAsync(ms) {
15504
- await _timers.advanceTimersByTimeAsync(ms);
15586
+ await timers().advanceTimersByTimeAsync(ms);
15505
15587
  return utils;
15506
15588
  },
15507
15589
  advanceTimersToNextTimer() {
15508
- _timers.advanceTimersToNextTimer();
15590
+ timers().advanceTimersToNextTimer();
15509
15591
  return utils;
15510
15592
  },
15511
15593
  async advanceTimersToNextTimerAsync() {
15512
- await _timers.advanceTimersToNextTimerAsync();
15594
+ await timers().advanceTimersToNextTimerAsync();
15513
15595
  return utils;
15514
15596
  },
15515
15597
  getTimerCount() {
15516
- return _timers.getTimerCount();
15598
+ return timers().getTimerCount();
15517
15599
  },
15518
15600
  setSystemTime(time) {
15519
15601
  const date = time instanceof Date ? time : new Date(time);
15520
15602
  _mockedDate = date;
15521
- _timers.setSystemTime(date);
15603
+ timers().setSystemTime(date);
15522
15604
  return utils;
15523
15605
  },
15524
15606
  getMockedSystemTime() {
15525
15607
  return _mockedDate;
15526
15608
  },
15527
15609
  getRealSystemTime() {
15528
- return _timers.getRealSystemTime();
15610
+ return timers().getRealSystemTime();
15529
15611
  },
15530
15612
  clearAllTimers() {
15531
- _timers.clearAllTimers();
15613
+ timers().clearAllTimers();
15532
15614
  return utils;
15533
15615
  },
15534
15616
  // mocks
@@ -15607,7 +15689,10 @@ function createVitest() {
15607
15689
  stubEnv(name, value) {
15608
15690
  if (!_stubsEnv.has(name))
15609
15691
  _stubsEnv.set(name, process.env[name]);
15610
- process.env[name] = value;
15692
+ if (_envBooleans.includes(name))
15693
+ process.env[name] = value ? "1" : "";
15694
+ else
15695
+ process.env[name] = String(value);
15611
15696
  return utils;
15612
15697
  },
15613
15698
  unstubAllGlobals() {
@@ -15652,7 +15737,7 @@ function createVitest() {
15652
15737
  var vitest = createVitest();
15653
15738
  var vi = vitest;
15654
15739
 
15655
- // ../../node_modules/vitest/dist/vendor/index.BeX1oZht.js
15740
+ // ../../node_modules/vitest/dist/vendor/index.0RrMQKD8.js
15656
15741
  init_esm_shims();
15657
15742
  function getRunningMode() {
15658
15743
  return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";