( matcherName: string, options: MatcherHintOptions, thrown: Thrown | null, expected: RegExp, )
| 143 | }; |
| 144 | |
| 145 | const toThrowExpectedRegExp = ( |
| 146 | matcherName: string, |
| 147 | options: MatcherHintOptions, |
| 148 | thrown: Thrown | null, |
| 149 | expected: RegExp, |
| 150 | ): SyncExpectationResult => { |
| 151 | const pass = thrown !== null && expected.test(thrown.message); |
| 152 | |
| 153 | const message = pass |
| 154 | ? () => |
| 155 | // eslint-disable-next-line prefer-template |
| 156 | matcherHint(matcherName, undefined, undefined, options) + |
| 157 | '\n\n' + |
| 158 | formatExpected('Expected pattern: not ', expected) + |
| 159 | (thrown !== null && thrown.hasMessage |
| 160 | ? formatReceived( |
| 161 | 'Received message: ', |
| 162 | thrown, |
| 163 | 'message', |
| 164 | expected, |
| 165 | ) + formatStack(thrown) |
| 166 | : formatReceived('Received value: ', thrown, 'value')) |
| 167 | : () => |
| 168 | // eslint-disable-next-line prefer-template |
| 169 | matcherHint(matcherName, undefined, undefined, options) + |
| 170 | '\n\n' + |
| 171 | formatExpected('Expected pattern: ', expected) + |
| 172 | (thrown === null |
| 173 | ? `\n${DID_NOT_THROW}` |
| 174 | : thrown.hasMessage |
| 175 | ? formatReceived('Received message: ', thrown, 'message') + |
| 176 | formatStack(thrown) |
| 177 | : formatReceived('Received value: ', thrown, 'value')); |
| 178 | |
| 179 | return {message, pass}; |
| 180 | }; |
| 181 | |
| 182 | type AsymmetricMatcher = { |
| 183 | asymmetricMatch: (received: unknown) => boolean; |
no test coverage detected