Comparing version 29.3.1 to 29.4.0
@@ -108,2 +108,3 @@ 'use strict'; | ||
return { | ||
customTesters: (0, _jestMatchersObject.getCustomEqualityTesters)(), | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
@@ -203,2 +204,3 @@ dontThrow: () => {}, | ||
} | ||
const matcherContext = this.getMatcherContext(); | ||
const result = | ||
@@ -208,3 +210,9 @@ this.sample.length === 0 || | ||
this.sample.every(item => | ||
other.some(another => (0, _expectUtils.equals)(item, another)) | ||
other.some(another => | ||
(0, _expectUtils.equals)( | ||
item, | ||
another, | ||
matcherContext.customTesters | ||
) | ||
) | ||
)); | ||
@@ -232,6 +240,11 @@ return this.inverse ? !result : result; | ||
let result = true; | ||
const matcherContext = this.getMatcherContext(); | ||
for (const property in this.sample) { | ||
if ( | ||
!hasProperty(other, property) || | ||
!(0, _expectUtils.equals)(this.sample[property], other[property]) | ||
!(0, _expectUtils.equals)( | ||
this.sample[property], | ||
other[property], | ||
matcherContext.customTesters | ||
) | ||
) { | ||
@@ -238,0 +251,0 @@ result = false; |
@@ -9,3 +9,4 @@ /** | ||
import type * as jestMatcherUtils from 'jest-matcher-utils'; | ||
import type {Tester} from '@jest/expect-utils'; | ||
import {Tester} from '@jest/expect-utils'; | ||
import {TesterContext} from '@jest/expect-utils'; | ||
@@ -47,2 +48,3 @@ export declare abstract class AsymmetricMatcher<T> | ||
assertions(numberOfAssertions: number): void; | ||
addEqualityTesters(testers: Array<Tester>): void; | ||
extend(matchers: MatchersObject): void; | ||
@@ -333,2 +335,3 @@ extractExpectedAssertionsErrors(): ExpectedAssertionsErrors; | ||
export declare interface MatcherUtils { | ||
customTesters: Array<Tester>; | ||
dontThrow(): void; | ||
@@ -364,2 +367,6 @@ equals: EqualsFunction; | ||
export {Tester}; | ||
export {TesterContext}; | ||
export {}; |
@@ -240,2 +240,3 @@ 'use strict'; | ||
const matcherUtilsThing = { | ||
customTesters: (0, _jestMatchersObject.getCustomEqualityTesters)(), | ||
// When throws is disabled, the matcher will not throw errors during test | ||
@@ -334,2 +335,4 @@ // execution but instead add them to the global matcher state. If a | ||
(0, _jestMatchersObject.setMatchers)(matchers, false, expect); | ||
expect.addEqualityTesters = customTesters => | ||
(0, _jestMatchersObject.addCustomEqualityTesters)(customTesters); | ||
expect.anything = _asymmetricMatchers.anything; | ||
@@ -336,0 +339,0 @@ expect.any = _asymmetricMatchers.any; |
@@ -10,2 +10,4 @@ 'use strict'; | ||
exports.getMatchers = | ||
exports.getCustomEqualityTesters = | ||
exports.addCustomEqualityTesters = | ||
exports.INTERNAL_MATCHER_FLAG = | ||
@@ -34,2 +36,3 @@ void 0; | ||
value: { | ||
customEqualityTesters: [], | ||
matchers: Object.create(null), | ||
@@ -102,1 +105,14 @@ state: defaultState | ||
exports.setMatchers = setMatchers; | ||
const getCustomEqualityTesters = () => | ||
globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters; | ||
exports.getCustomEqualityTesters = getCustomEqualityTesters; | ||
const addCustomEqualityTesters = newTesters => { | ||
if (!Array.isArray(newTesters)) { | ||
throw new TypeError( | ||
`expect.customEqualityTesters: Must be set to an array of Testers. Was given "${(0, | ||
_jestGetType.getType)(newTesters)}"` | ||
); | ||
} | ||
globalThis[JEST_MATCHERS_OBJECT].customEqualityTesters.push(...newTesters); | ||
}; | ||
exports.addCustomEqualityTesters = addCustomEqualityTesters; |
@@ -65,3 +65,3 @@ 'use strict'; | ||
expected, | ||
toStrictEqualTesters, | ||
[...this.customTesters, ...toStrictEqualTesters], | ||
true | ||
@@ -73,2 +73,3 @@ ) | ||
(0, _expectUtils.equals)(received, expected, [ | ||
...this.customTesters, | ||
_expectUtils.iterableEquality | ||
@@ -667,2 +668,3 @@ ]) | ||
(0, _expectUtils.equals)(item, expected, [ | ||
...this.customTesters, | ||
_expectUtils.iterableEquality | ||
@@ -709,3 +711,6 @@ ]) | ||
const index = Array.from(received).findIndex(item => | ||
(0, _expectUtils.equals)(item, expected, [_expectUtils.iterableEquality]) | ||
(0, _expectUtils.equals)(item, expected, [ | ||
...this.customTesters, | ||
_expectUtils.iterableEquality | ||
]) | ||
); | ||
@@ -751,2 +756,3 @@ const pass = index !== -1; | ||
const pass = (0, _expectUtils.equals)(received, expected, [ | ||
...this.customTesters, | ||
_expectUtils.iterableEquality | ||
@@ -947,2 +953,3 @@ ]); | ||
? (0, _expectUtils.equals)(value, expectedValue, [ | ||
...this.customTesters, | ||
_expectUtils.iterableEquality | ||
@@ -1187,2 +1194,3 @@ ]) | ||
const pass = (0, _expectUtils.equals)(received, expected, [ | ||
...this.customTesters, | ||
_expectUtils.iterableEquality, | ||
@@ -1219,3 +1227,7 @@ _expectUtils.subsetEquality | ||
expected, | ||
(0, _expectUtils.getObjectSubset)(received, expected), | ||
(0, _expectUtils.getObjectSubset)( | ||
received, | ||
expected, | ||
this.customTesters | ||
), | ||
EXPECTED_LABEL, | ||
@@ -1240,3 +1252,3 @@ RECEIVED_LABEL, | ||
expected, | ||
toStrictEqualTesters, | ||
[...this.customTesters, ...toStrictEqualTesters], | ||
true | ||
@@ -1243,0 +1255,0 @@ ); |
@@ -10,2 +10,3 @@ 'use strict'; | ||
var _jestMatcherUtils = require('jest-matcher-utils'); | ||
var _jestMatchersObject = require('./jestMatchersObject'); | ||
/** | ||
@@ -41,3 +42,6 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
const isEqualValue = (expected, received) => | ||
(0, _expectUtils.equals)(expected, received, [_expectUtils.iterableEquality]); | ||
(0, _expectUtils.equals)(expected, received, [ | ||
...(0, _jestMatchersObject.getCustomEqualityTesters)(), | ||
_expectUtils.iterableEquality | ||
]); | ||
const isEqualCall = (expected, received) => | ||
@@ -44,0 +48,0 @@ received.length === expected.length && isEqualValue(expected, received); |
{ | ||
"name": "expect", | ||
"version": "29.3.1", | ||
"version": "29.4.0", | ||
"repository": { | ||
@@ -22,12 +22,12 @@ "type": "git", | ||
"dependencies": { | ||
"@jest/expect-utils": "^29.3.1", | ||
"@jest/expect-utils": "^29.4.0", | ||
"jest-get-type": "^29.2.0", | ||
"jest-matcher-utils": "^29.3.1", | ||
"jest-message-util": "^29.3.1", | ||
"jest-util": "^29.3.1" | ||
"jest-matcher-utils": "^29.4.0", | ||
"jest-message-util": "^29.4.0", | ||
"jest-util": "^29.4.0" | ||
}, | ||
"devDependencies": { | ||
"@fast-check/jest": "^1.3.0", | ||
"@jest/test-utils": "^29.3.1", | ||
"@tsd/typescript": "~4.8.2", | ||
"@jest/test-utils": "^29.4.0", | ||
"@tsd/typescript": "^4.9.0", | ||
"chalk": "^4.0.0", | ||
@@ -43,3 +43,3 @@ "immutable": "^4.0.0", | ||
}, | ||
"gitHead": "05deb8393c4ad71e19be2567b704dfd3a2ab5fc9" | ||
"gitHead": "4bc0e8acaf990e6618a7bed1dca67760c20bb12a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
270434
14
4389
Updated@jest/expect-utils@^29.4.0
Updatedjest-matcher-utils@^29.4.0
Updatedjest-message-util@^29.4.0
Updatedjest-util@^29.4.0