( matcherName: string, options: MatcherHintOptions, thrown: Thrown | null, )
| 376 | }; |
| 377 | |
| 378 | const toThrow = ( |
| 379 | matcherName: string, |
| 380 | options: MatcherHintOptions, |
| 381 | thrown: Thrown | null, |
| 382 | ): SyncExpectationResult => { |
| 383 | const pass = thrown !== null; |
| 384 | |
| 385 | const message = pass |
| 386 | ? () => |
| 387 | // eslint-disable-next-line prefer-template |
| 388 | matcherHint(matcherName, undefined, '', options) + |
| 389 | '\n\n' + |
| 390 | (thrown !== null && thrown.hasMessage |
| 391 | ? formatReceived('Error name: ', thrown, 'name') + |
| 392 | formatReceived('Error message: ', thrown, 'message') + |
| 393 | formatStack(thrown) |
| 394 | : formatReceived('Thrown value: ', thrown, 'value')) |
| 395 | : () => |
| 396 | // eslint-disable-next-line prefer-template |
| 397 | matcherHint(matcherName, undefined, '', options) + |
| 398 | '\n\n' + |
| 399 | DID_NOT_THROW; |
| 400 | |
| 401 | return {message, pass}; |
| 402 | }; |
| 403 | |
| 404 | const formatExpected = (label: string, expected: unknown) => |
| 405 | `${label + printExpected(expected)}\n`; |
no test coverage detected