(result)
| 252 | }) |
| 253 | |
| 254 | async function printReport(result) { |
| 255 | const failedTestsAndErrors = result.tests.filter(t => t.err) |
| 256 | |
| 257 | if (!failedTestsAndErrors.length) return |
| 258 | |
| 259 | debug(failedTestsAndErrors.map(t => serializeTest(t) + '\n' + serializeError(t.err))) |
| 260 | |
| 261 | try { |
| 262 | if (failedTestsAndErrors.length >= config.clusterize) { |
| 263 | const response = await clusterize(failedTestsAndErrors) |
| 264 | printHeader() |
| 265 | console.log(response) |
| 266 | return |
| 267 | } |
| 268 | |
| 269 | output.plugin('analyze', `Analyzing first ${config.analyze} failed tests...`) |
| 270 | |
| 271 | // we pick only unique errors to not repeat answers |
| 272 | const uniqueErrors = failedTestsAndErrors.filter((item, index, array) => { |
| 273 | return array.findIndex(t => t.err?.message === item.err?.message) === index |
| 274 | }) |
| 275 | |
| 276 | for (let i = 0; i < config.analyze; i++) { |
| 277 | if (!uniqueErrors[i]) break |
| 278 | |
| 279 | const response = await analyze(uniqueErrors[i]) |
| 280 | if (!response) { |
| 281 | break |
| 282 | } |
| 283 | |
| 284 | printHeader() |
| 285 | console.log() |
| 286 | console.log('--------------------------------') |
| 287 | console.log(arrowRight, colors.bold.white(uniqueErrors[i].fullTitle()), config.vision ? '👀' : '') |
| 288 | console.log() |
| 289 | console.log() |
| 290 | console.log(response) |
| 291 | console.log() |
| 292 | } |
| 293 | } catch (err) { |
| 294 | console.error('Error analyzing failed tests', err) |
| 295 | } |
| 296 | |
| 297 | if (!Object.keys(Container.plugins()).includes('pageInfo')) { |
| 298 | console.log('To improve analysis, enable pageInfo plugin to get more context for failed tests.') |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | let hasPrintedHeader = false |
| 303 |
no test coverage detected