Add the Line Reporter
parent
64d10c8dfb
commit
7a8a4ad629
3
index.js
3
index.js
|
@ -1,5 +1,6 @@
|
|||
|
||||
import { consolereporter } from './consolereporter.js'
|
||||
import { linereporter } from './linereporter.js'
|
||||
import { totalreporter } from './totalreporter.js'
|
||||
import { runifmain } from './runifmain.js'
|
||||
|
||||
|
@ -66,5 +67,5 @@ const metaltest = (title) => {
|
|||
return runner
|
||||
}
|
||||
|
||||
export { metaltest, consolereporter, totalreporter, runifmain }
|
||||
export { metaltest, consolereporter, linereporter, totalreporter, runifmain }
|
||||
export default metaltest
|
|
@ -0,0 +1,34 @@
|
|||
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 }
|
Loading…
Reference in New Issue