2022-12-05 16:50:37 -05:00
|
|
|
import chalk from 'chalk'
|
|
|
|
|
|
|
|
const log = (...args) => process.stdout.write(...args)
|
|
|
|
|
|
|
|
const errorreporter = () => {
|
|
|
|
const report = {
|
|
|
|
end: (stats) => {
|
|
|
|
const { testFail } = stats
|
|
|
|
|
|
|
|
for (const test of testFail) {
|
|
|
|
log('\n' + chalk.redBright(test.name) + '\n')
|
|
|
|
prettyError(test.error)
|
|
|
|
log('\n')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return report
|
|
|
|
}
|
|
|
|
|
2022-12-05 17:07:06 -05:00
|
|
|
import { stackParser } from '../lib/stackparser.js'
|
2022-12-05 16:50:37 -05:00
|
|
|
const prettyError = (error) => {
|
|
|
|
if (typeof error == 'string') {
|
|
|
|
log(chalk.yellowBright(error))
|
|
|
|
log('\n')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const stack = stackParser(error.stack)
|
|
|
|
log(chalk.yellowBright(stack.title) + '\n')
|
|
|
|
|
|
|
|
if (stack.diff != '\n ')
|
|
|
|
log(chalk.white(stack.diff))
|
|
|
|
|
|
|
|
if (stack.where != '')
|
|
|
|
log(chalk.gray(stack.where) + '\n')
|
|
|
|
}
|
|
|
|
|
|
|
|
export { errorreporter }
|