@jest/expect-utils 30.0.0-alpha.2 → 30.0.0-alpha.4

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 (3) hide show
  1. package/LICENSE +1 -0
  2. package/build/index.js +14 -10
  3. package/package.json +4 -6
package/LICENSE CHANGED
@@ -1,6 +1,7 @@
1
1
  MIT License
2
2
 
3
3
  Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ Copyright Contributors to the Jest project.
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
package/build/index.js CHANGED
@@ -170,8 +170,8 @@ function eq(a, b, aStack, bStack, customTesters, strictCheck) {
170
170
  const testerContext = {
171
171
  equals
172
172
  };
173
- for (let i = 0; i < customTesters.length; i++) {
174
- const customTesterResult = customTesters[i].call(testerContext, a, b, customTesters);
173
+ for (const item of customTesters) {
174
+ const customTesterResult = item.call(testerContext, a, b, customTesters);
175
175
  if (customTesterResult !== undefined) {
176
176
  return customTesterResult;
177
177
  }
@@ -293,7 +293,7 @@ function keys(obj, hasKey) {
293
293
  keys.push(key);
294
294
  }
295
295
  }
296
- return keys.concat(Object.getOwnPropertySymbols(obj).filter(symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable));
296
+ return [...keys, ...Object.getOwnPropertySymbols(obj).filter(symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable)];
297
297
  }
298
298
  function hasKey(obj, key) {
299
299
  return Object.prototype.hasOwnProperty.call(obj, key);
@@ -526,10 +526,11 @@ aStack = [], bStack = []) => {
526
526
  exports.iterableEquality = iterableEquality;
527
527
  const entries = obj => {
528
528
  if (!isObject(obj)) return [];
529
- return Object.getOwnPropertySymbols(obj).filter(key => key !== Symbol.iterator).map(key => [key, obj[key]]).concat(Object.entries(obj));
529
+ const symbolProperties = Object.getOwnPropertySymbols(obj).filter(key => key !== Symbol.iterator).map(key => [key, obj[key]]);
530
+ return [...symbolProperties, ...Object.entries(obj)];
530
531
  };
531
532
  const isObject = a => a !== null && typeof a === 'object';
532
- const isObjectWithKeys = a => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
533
+ const isObjectWithKeys = a => isObject(a) && !(a instanceof Error) && !Array.isArray(a) && !(a instanceof Date) && !(a instanceof Set) && !(a instanceof Map);
533
534
  const subsetEquality = (object, subset, customTesters = []) => {
534
535
  const filteredCustomTesters = customTesters.filter(t => t !== subsetEquality);
535
536
 
@@ -540,12 +541,13 @@ const subsetEquality = (object, subset, customTesters = []) => {
540
541
  if (!isObjectWithKeys(subset)) {
541
542
  return undefined;
542
543
  }
543
- return getObjectKeys(subset).every(key => {
544
+ if (seenReferences.has(subset)) return undefined;
545
+ seenReferences.set(subset, true);
546
+ const matchResult = getObjectKeys(subset).every(key => {
544
547
  if (isObjectWithKeys(subset[key])) {
545
548
  if (seenReferences.has(subset[key])) {
546
549
  return (0, _jasmineUtils.equals)(object[key], subset[key], filteredCustomTesters);
547
550
  }
548
- seenReferences.set(subset[key], true);
549
551
  }
550
552
  const result = object != null && hasPropertyInObject(object, key) && (0, _jasmineUtils.equals)(object[key], subset[key], [...filteredCustomTesters, subsetEqualityWithContext(seenReferences)]);
551
553
  // The main goal of using seenReference is to avoid circular node on tree.
@@ -556,6 +558,8 @@ const subsetEquality = (object, subset, customTesters = []) => {
556
558
  seenReferences.delete(subset[key]);
557
559
  return result;
558
560
  });
561
+ seenReferences.delete(subset);
562
+ return matchResult;
559
563
  };
560
564
  return subsetEqualityWithContext()(object, subset);
561
565
  };
@@ -624,13 +628,13 @@ const pathAsArray = propertyPath => {
624
628
  }
625
629
 
626
630
  // will match everything that's not a dot or a bracket, and "" for consecutive dots.
627
- const pattern = RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g');
631
+ const pattern = new RegExp('[^.[\\]]+|(?=(?:\\.)(?:\\.|$))', 'g');
628
632
 
629
633
  // Because the regex won't match a dot in the beginning of the path, if present.
630
634
  if (propertyPath[0] === '.') {
631
635
  properties.push('');
632
636
  }
633
- propertyPath.replace(pattern, match => {
637
+ propertyPath.replaceAll(pattern, match => {
634
638
  properties.push(match);
635
639
  return match;
636
640
  });
@@ -653,7 +657,7 @@ exports.isError = isError;
653
657
  function emptyObject(obj) {
654
658
  return obj && typeof obj === 'object' ? Object.keys(obj).length === 0 : false;
655
659
  }
656
- const MULTILINE_REGEXP = /[\r\n]/;
660
+ const MULTILINE_REGEXP = /[\n\r]/;
657
661
  const isOneline = (expected, received) => typeof expected === 'string' && typeof received === 'string' && (!MULTILINE_REGEXP.test(expected) || !MULTILINE_REGEXP.test(received));
658
662
  exports.isOneline = isOneline;
659
663
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jest/expect-utils",
3
- "version": "30.0.0-alpha.2",
3
+ "version": "30.0.0-alpha.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/jestjs/jest.git",
@@ -19,13 +19,11 @@
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "dependencies": {
22
- "jest-get-type": "30.0.0-alpha.2"
22
+ "jest-get-type": "30.0.0-alpha.4"
23
23
  },
24
24
  "devDependencies": {
25
- "@tsd/typescript": "^5.0.4",
26
25
  "immutable": "^4.0.0",
27
- "jest-matcher-utils": "30.0.0-alpha.2",
28
- "tsd-lite": "^0.8.0"
26
+ "jest-matcher-utils": "30.0.0-alpha.4"
29
27
  },
30
28
  "engines": {
31
29
  "node": "^16.10.0 || ^18.12.0 || >=20.0.0"
@@ -33,5 +31,5 @@
33
31
  "publishConfig": {
34
32
  "access": "public"
35
33
  },
36
- "gitHead": "c04d13d7abd22e47b0997f6027886aed225c9ce4"
34
+ "gitHead": "32b966f988d47a7673d2ef4b92e834dab7d66f07"
37
35
  }