2022-12-04 16:07:28 -05:00
|
|
|
import chalk from 'chalk'
|
2022-12-04 23:40:07 -05:00
|
|
|
import { stackParser } from './stackparser.js'
|
2022-12-04 16:07:28 -05:00
|
|
|
|
|
|
|
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))
|
|
|
|
|
2022-12-04 23:40:07 -05:00
|
|
|
const stack = stackParser(testFail[0].error.stack)
|
|
|
|
console.log(stack.diff)
|
2022-12-04 16:07:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return report
|
|
|
|
}
|
|
|
|
|
|
|
|
export { linereporter }
|