MCPcopy
hub / github.com/jestjs/jest / toStrictEqual

Function toStrictEqual

packages/expect/src/matchers.ts:951–991  ·  view source on GitHub ↗
(received: unknown, expected: unknown)

Source from the content-addressed store, hash-verified

949 },
950
951 toStrictEqual(received: unknown, expected: unknown) {
952 const matcherName = 'toStrictEqual';
953 const options: MatcherHintOptions = {
954 comment: 'deep equality',
955 isNot: this.isNot,
956 promise: this.promise,
957 };
958
959 const pass = equals(
960 received,
961 expected,
962 [...this.customTesters, ...toStrictEqualTesters],
963 true,
964 );
965
966 const message = pass
967 ? () =>
968 // eslint-disable-next-line prefer-template
969 matcherHint(matcherName, undefined, undefined, options) +
970 '\n\n' +
971 `Expected: not ${printExpected(expected)}\n` +
972 (stringify(expected) === stringify(received)
973 ? ''
974 : `Received: ${printReceived(received)}`)
975 : () =>
976 // eslint-disable-next-line prefer-template
977 matcherHint(matcherName, undefined, undefined, options) +
978 '\n\n' +
979 printDiffOrStringify(
980 expected,
981 received,
982 EXPECTED_LABEL,
983 RECEIVED_LABEL,
984 isExpand(this.expand),
985 );
986
987 // Passing the actual and expected objects so that a custom reporter
988 // could access them, for example in order to display a custom visual diff,
989 // or create a different error message
990 return {actual: received, expected, message, name: matcherName, pass};
991 },
992};
993
994export default matchers;

Callers

nothing calls this directly

Calls 7

equalsFunction · 0.90
matcherHintFunction · 0.90
printExpectedFunction · 0.90
stringifyFunction · 0.90
printReceivedFunction · 0.90
printDiffOrStringifyFunction · 0.90
isExpandFunction · 0.70

Tested by

no test coverage detected