()
| 186 | } |
| 187 | |
| 188 | async result() { |
| 189 | try { |
| 190 | const Container = await getContainer() |
| 191 | Container.result().addStats(this.stats) |
| 192 | Container.result().finish() |
| 193 | |
| 194 | const stats = Container.result().stats |
| 195 | console.log() |
| 196 | |
| 197 | // passes |
| 198 | if (stats.failures) { |
| 199 | output.print(output.styles.bold('-- FAILURES:')) |
| 200 | } |
| 201 | |
| 202 | const failuresLog = [] |
| 203 | |
| 204 | // failures |
| 205 | if (stats.failures) { |
| 206 | for (const test of this.failures) { |
| 207 | if (test.err && typeof test.err.fetchDetails === 'function') { |
| 208 | try { |
| 209 | await test.err.fetchDetails() |
| 210 | } catch (e) { |
| 211 | // ignore fetch errors |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | // append step traces |
| 217 | const Container = await getContainer() |
| 218 | this.failures = this.failures.map(test => { |
| 219 | // we will change the stack trace, so we need to clone the test |
| 220 | const err = test.err |
| 221 | |
| 222 | let log = '' |
| 223 | let originalMessage = err.message |
| 224 | |
| 225 | if (err instanceof AssertionFailedError) { |
| 226 | err.message = err.inspect() |
| 227 | } |
| 228 | |
| 229 | // multi-line error messages (for Playwright) |
| 230 | if (err.message && err.message.includes('\n')) { |
| 231 | const lines = err.message.split('\n') |
| 232 | const truncatedLines = lines.slice(0, 5) |
| 233 | if (lines.length > 5) { |
| 234 | truncatedLines.push('...') |
| 235 | } |
| 236 | err.message = truncatedLines.join('\n').replace(/^/gm, ' ').trim() |
| 237 | } |
| 238 | |
| 239 | // add new line before the message |
| 240 | err.message = '\n ' + err.message |
| 241 | |
| 242 | // explicitly show file with error |
| 243 | if (test.file) { |
| 244 | log += `\n${output.styles.basic(figures.circle)} ${output.styles.section('File:')} file://${test.file}\n` |
| 245 | } |
no test coverage detected