34 lines
864 B
JavaScript
34 lines
864 B
JavaScript
|
import chalk from 'chalk'
|
||
|
|
||
|
const linereporter = () => {
|
||
|
const lines = []
|
||
|
|
||
|
const report = {
|
||
|
start: (title) => {
|
||
|
console.log(chalk.cyanBright(title))
|
||
|
},
|
||
|
success: (test) => {
|
||
|
console.log(chalk.greenBright('✓'), test.name)
|
||
|
},
|
||
|
fail: (test, e) => {
|
||
|
const line = e.stack.match(/at.*:(.*):/)[1]
|
||
|
lines.push(line)
|
||
|
console.log(chalk.redBright('✗'), line, test.name)
|
||
|
},
|
||
|
end: (stats) => {
|
||
|
const { success, fail, testFail } = stats
|
||
|
console.log(chalk.redBright('✗ ' + fail), chalk.greenBright('✓ ' + success))
|
||
|
|
||
|
if (testFail.length == 1) {
|
||
|
console.log('Lines in error', chalk.redBright(lines))
|
||
|
|
||
|
const { error: { stack: e } } = testFail[0]
|
||
|
console.log(e.slice(e.indexOf('\n') + 1, e.indexOf(' at') - 1));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return report
|
||
|
}
|
||
|
|
||
|
export { linereporter }
|