Extract the error reporter
parent
979f078ac3
commit
7bde58b5ed
|
@ -15,36 +15,11 @@ const consolereporter = () => {
|
|||
log(chalk.redBright('✗ '))
|
||||
},
|
||||
end: (stats) => {
|
||||
const { testFail } = stats
|
||||
log('\n')
|
||||
|
||||
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 { consolereporter }
|
|
@ -0,0 +1,39 @@
|
|||
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 }
|
|
@ -1,3 +1,4 @@
|
|||
export { consolereporter } from './consolereporter.js'
|
||||
export { linereporter } from './linereporter.js'
|
||||
export { totalreporter } from './totalreporter.js'
|
||||
export { errorreporter } from './errorreporter.js'
|
Loading…
Reference in New Issue