34 lines
760 B
JavaScript
34 lines
760 B
JavaScript
import chalk from 'chalk'
|
|
import { log } from '../lib/log.js'
|
|
import { stackParser } from '../lib/stackparser.js'
|
|
|
|
const showError = (testsFail) => {
|
|
for (const test of testsFail) {
|
|
log('\n' + chalk.redBright(test.name) + '\n')
|
|
prettyError(test)
|
|
}
|
|
}
|
|
|
|
const prettyError = (test) => {
|
|
const { error } = test
|
|
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 != '')
|
|
log(chalk.white(stack.diff) + '\n')
|
|
|
|
// if (stack.where != '')
|
|
// log(chalk.gray(stack.where) + '\n')
|
|
|
|
log(chalk.gray(test.at.summary) + '\n')
|
|
log(chalk.gray(stack.stacks.join('\n')) + '\n')
|
|
}
|
|
|
|
export { showError }
|