MCPcopy
hub / github.com/codeceptjs/CodeceptJS / serializeError

Function serializeError

lib/plugin/analyze.js:339–366  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

337}
338
339function serializeError(error) {
340 if (typeof error === 'string') {
341 return error
342 }
343
344 if (!error) return
345
346 let errorMessage = 'ERROR: ' + error.message
347
348 if (error.inspect) {
349 errorMessage = 'ERROR: ' + error.inspect()
350 }
351
352 if (error.stack) {
353 errorMessage +=
354 '\n' +
355 error.stack
356 .replace(store.codeceptDir || '', '.')
357 .split('\n')
358 .map(line => line.replace(ansiRegExp(), ''))
359 .slice(0, 5)
360 .join('\n')
361 }
362 if (error.steps) {
363 errorMessage += '\n STEPS: ' + error.steps.map(s => s.toCode()).join('\n')
364 }
365 return errorMessage
366}
367
368function serializeTest(test) {
369 if (!test.uid) return

Callers 4

simplifyMethod · 0.90
serializeTestFunction · 0.90
analyze.jsFile · 0.70
printReportFunction · 0.70

Calls 2

ansiRegExpFunction · 0.90
toCodeMethod · 0.45

Tested by

no test coverage detected