MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / printReport

Function printReport

lib/plugin/analyze.js:254–300  ·  view source on GitHub ↗
(result)

Source from the content-addressed store, hash-verified

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

Callers 1

analyze.jsFile · 0.85

Calls 10

debugFunction · 0.85
clusterizeFunction · 0.85
printHeaderFunction · 0.85
analyzeFunction · 0.85
filterMethod · 0.80
logMethod · 0.80
includesMethod · 0.80
pluginsMethod · 0.80
serializeTestFunction · 0.70
serializeErrorFunction · 0.70

Tested by

no test coverage detected