Extract the log function
parent
ac8481ef64
commit
5c69828b1d
|
@ -1,30 +1,32 @@
|
||||||
import chalk from 'chalk'
|
import chalk from 'chalk'
|
||||||
import { stackParser } from '../stackparser.js'
|
import { stackParser } from '../stackparser.js'
|
||||||
|
|
||||||
|
const log = (...args) => console.log(...args)
|
||||||
|
|
||||||
const linereporter = () => {
|
const linereporter = () => {
|
||||||
const lines = []
|
const lines = []
|
||||||
|
|
||||||
const report = {
|
const report = {
|
||||||
start: (title) => {
|
start: (title) => {
|
||||||
console.log(chalk.cyanBright(title))
|
log(chalk.cyanBright(title))
|
||||||
},
|
},
|
||||||
success: (test) => {
|
success: (test) => {
|
||||||
console.log(chalk.greenBright('✓'), test.name)
|
log(chalk.greenBright('✓'), test.name)
|
||||||
},
|
},
|
||||||
fail: (test, e) => {
|
fail: (test, e) => {
|
||||||
const line = e.stack.match(/at.*:(.*):/)[1]
|
const line = e.stack.match(/at.*:(.*):/)[1]
|
||||||
lines.push(line)
|
lines.push(line)
|
||||||
console.log(chalk.redBright('✗'), line, test.name)
|
log(chalk.redBright('✗'), line, test.name)
|
||||||
},
|
},
|
||||||
end: (stats) => {
|
end: (stats) => {
|
||||||
const { success, fail, testFail } = stats
|
const { success, fail, testFail } = stats
|
||||||
console.log(chalk.redBright('✗ ' + fail), chalk.greenBright('✓ ' + success))
|
log(chalk.redBright('✗ ' + fail), chalk.greenBright('✓ ' + success))
|
||||||
|
|
||||||
if (testFail.length == 1) {
|
if (testFail.length == 1) {
|
||||||
console.log('Lines in error', chalk.redBright(lines))
|
log('Lines in error', chalk.redBright(lines))
|
||||||
|
|
||||||
const stack = stackParser(testFail[0].error.stack)
|
const stack = stackParser(testFail[0].error.stack)
|
||||||
console.log(stack.diff)
|
log(stack.diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue