(didThrow, actual, expected)
| 53 | } |
| 54 | |
| 55 | function matchError(didThrow, actual, expected) { |
| 56 | const normalizedActual = |
| 57 | didThrow && |
| 58 | stripAddedLinebreaks( |
| 59 | stripAddedIndentation( |
| 60 | typeof actual === 'object' && 'message' in actual |
| 61 | ? actual.message |
| 62 | : String(actual), |
| 63 | ), |
| 64 | ) |
| 65 | const normalizedExpected = stripAddedLinebreaks( |
| 66 | stripAddedIndentation(expected), |
| 67 | ) |
| 68 | |
| 69 | return { |
| 70 | pass: this.isNot === !didThrow && normalizedActual === normalizedExpected, |
| 71 | message: () => |
| 72 | [ |
| 73 | this.utils.matcherHint( |
| 74 | 'toThrowErrorMatchingInlineSnapshot', |
| 75 | undefined, |
| 76 | undefined, |
| 77 | { |
| 78 | isNot: this.isNot, |
| 79 | promise: this.promise, |
| 80 | }, |
| 81 | ), |
| 82 | '', |
| 83 | didThrow |
| 84 | ? this.utils.diff(normalizedExpected, normalizedActual, { |
| 85 | expand: this.expand, |
| 86 | }) |
| 87 | : '[Did not throw]', |
| 88 | ].join('\n'), |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | function stripAddedLinebreaks(normalizedSnapshot) { |
| 93 | return normalizedSnapshot.startsWith('\n') && |
nothing calls this directly
no test coverage detected