( matcherName: string, options: MatcherHintOptions, thrown: Thrown | null, expected: string, )
| 339 | }; |
| 340 | |
| 341 | const toThrowExpectedString = ( |
| 342 | matcherName: string, |
| 343 | options: MatcherHintOptions, |
| 344 | thrown: Thrown | null, |
| 345 | expected: string, |
| 346 | ): SyncExpectationResult => { |
| 347 | const pass = thrown !== null && thrown.message.includes(expected); |
| 348 | |
| 349 | const message = pass |
| 350 | ? () => |
| 351 | // eslint-disable-next-line prefer-template |
| 352 | matcherHint(matcherName, undefined, undefined, options) + |
| 353 | '\n\n' + |
| 354 | formatExpected('Expected substring: not ', expected) + |
| 355 | (thrown !== null && thrown.hasMessage |
| 356 | ? formatReceived( |
| 357 | 'Received message: ', |
| 358 | thrown, |
| 359 | 'message', |
| 360 | expected, |
| 361 | ) + formatStack(thrown) |
| 362 | : formatReceived('Received value: ', thrown, 'value')) |
| 363 | : () => |
| 364 | // eslint-disable-next-line prefer-template |
| 365 | matcherHint(matcherName, undefined, undefined, options) + |
| 366 | '\n\n' + |
| 367 | formatExpected('Expected substring: ', expected) + |
| 368 | (thrown === null |
| 369 | ? `\n${DID_NOT_THROW}` |
| 370 | : thrown.hasMessage |
| 371 | ? formatReceived('Received message: ', thrown, 'message') + |
| 372 | formatStack(thrown) |
| 373 | : formatReceived('Received value: ', thrown, 'value')); |
| 374 | |
| 375 | return {message, pass}; |
| 376 | }; |
| 377 | |
| 378 | const toThrow = ( |
| 379 | matcherName: string, |
no test coverage detected