39 lines
788 B
JavaScript
39 lines
788 B
JavaScript
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
|
|
}
|
|
|
|
import { stackParser } from '../stackparser.js'
|
|
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 } |