(received: unknown, expected: unknown)
| 73 | |
| 74 | const matchers: MatchersObject = { |
| 75 | toBe(received: unknown, expected: unknown) { |
| 76 | const matcherName = class="st">'toBe'; |
| 77 | const options: MatcherHintOptions = { |
| 78 | comment: class="st">'Object.is equality', |
| 79 | isNot: this.isNot, |
| 80 | promise: this.promise, |
| 81 | }; |
| 82 | |
| 83 | const pass = Object.is(received, expected); |
| 84 | |
| 85 | const message = pass |
| 86 | ? () => |
| 87 | class="cm">// eslint-disable-next-line prefer-template |
| 88 | matcherHint(matcherName, undefined, undefined, options) + |
| 89 | class="st">'\n\n' + |
| 90 | `Expected: not ${printExpected(expected)}` |
| 91 | : () => { |
| 92 | const expectedType = getType(expected); |
| 93 | |
| 94 | let deepEqualityName = null; |
| 95 | if (expectedType !== class="st">'map' && expectedType !== class="st">'set') { |
| 96 | class="cm">// If deep equality passes when referential identity fails, |
| 97 | class="cm">// but exclude map and set until review of their equality logic. |
| 98 | if ( |
| 99 | equals( |
| 100 | received, |
| 101 | expected, |
| 102 | [...this.customTesters, ...toStrictEqualTesters], |
| 103 | true, |
| 104 | ) |
| 105 | ) { |
| 106 | deepEqualityName = class="st">'toStrictEqual'; |
| 107 | } else if ( |
| 108 | equals(received, expected, [ |
| 109 | ...this.customTesters, |
| 110 | iterableEquality, |
| 111 | ]) |
| 112 | ) { |
| 113 | deepEqualityName = class="st">'toEqual'; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return ( |
| 118 | class="cm">// eslint-disable-next-line prefer-template |
| 119 | matcherHint(matcherName, undefined, undefined, options) + |
| 120 | class="st">'\n\n' + |
| 121 | (deepEqualityName === null |
| 122 | ? class="st">'' |
| 123 | : `${DIM_COLOR( |
| 124 | `If it should pass with deep equality, replace class="st">"${matcherName}" with class="st">"${deepEqualityName}"`, |
| 125 | )}\n\n`) + |
| 126 | printDiffOrStringify( |
| 127 | expected, |
| 128 | received, |
| 129 | EXPECTED_LABEL, |
| 130 | RECEIVED_LABEL, |
| 131 | isExpand(this.expand), |
| 132 | ) |
nothing calls this directly
no test coverage detected