(err: any)
| 117 | } |
| 118 | } |
| 119 | function formatException(err: any) { |
| 120 | const props = ['actual', 'expected', 'operator', 'generatedMessage']; |
| 121 | let message = ''; |
| 122 | if (typeof err.inspect === 'function') { |
| 123 | message = err.inspect() + ''; |
| 124 | } else if (err.message && typeof err.message.toString === 'function') { |
| 125 | message = err.message + ''; |
| 126 | } |
| 127 | const error: Record<string, any> = { |
| 128 | name: err.name, |
| 129 | message, |
| 130 | stack: err.stack, |
| 131 | showDiff: err.showDiff, |
| 132 | inspect: '' |
| 133 | }; |
| 134 | props.forEach((prop) => { |
| 135 | try { |
| 136 | error[prop] = JSON.parse(JSON.stringify(err[prop])); |
| 137 | } catch { |
| 138 | error[prop] = '<..?..>'; |
| 139 | } |
| 140 | }); |
| 141 | return error as Exception; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * We use this to hijack all of the console output, so we have all of the output generated when a test fails. |
no test coverage detected