Skip to content

Commit

Permalink
fix: added inherited string keys check on subsetEquality method (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
lpizzinidev committed Feb 15, 2023
1 parent 76ec2a4 commit af5d5a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@

### Fixes

- `[@jest/expect-utils]` `subsetEquality` should consider also an object's inherited string keys ([#13824](https://github.com/facebook/jest/pull/13824))
- `[jest-mock]` Clear mock state when `jest.restoreAllMocks()` is called ([#13867](https://github.com/facebook/jest/pull/13867))
- `[jest-mock]` Prevent `mockImplementationOnce` and `mockReturnValueOnce` bleeding into `withImplementation` ([#13888](https://github.com/facebook/jest/pull/13888))
- `[jest-mock]` Do not restore mocks when `jest.resetAllMocks()` is called ([#13866](https://github.com/facebook/jest/pull/13866))
Expand Down
4 changes: 1 addition & 3 deletions packages/expect-utils/src/utils.ts
Expand Up @@ -47,8 +47,6 @@ const hasPropertyInObject = (object: object, key: string | symbol): boolean => {
// the prototype chain for string keys but not for symbols. (Otherwise, it
// could find values such as a Set or Map's Symbol.toStringTag, with unexpected
// results.)
//
// Compare with subsetEquality's use of Reflect.ownKeys.
const getObjectKeys = (object: object) => [
...Object.keys(object),
...Object.getOwnPropertySymbols(object),
Expand Down Expand Up @@ -343,7 +341,7 @@ export const subsetEquality = (
return undefined;
}

return Reflect.ownKeys(subset).every(key => {
return getObjectKeys(subset).every(key => {
if (isObjectWithKeys(subset[key])) {
if (seenReferences.has(subset[key])) {
return equals(object[key], subset[key], filteredCustomTesters);
Expand Down

0 comments on commit af5d5a1

Please sign in to comment.