import chalk from 'chalk' import { stackParser } from '../stackparser.js' const log = (...args) => console.log(...args) const linereporter = () => { const lines = [] const report = { start: (title) => { log(chalk.cyanBright(title)) }, success: (test) => { log(chalk.greenBright('✓'), test.name) }, fail: (test, e) => { const line = e.stack.match(/at.*:(.*):/)[1] lines.push(line) log(chalk.redBright('✗'), line, test.name) }, end: (stats) => { const { success, fail, testFail } = stats log(chalk.redBright('✗ ' + fail), chalk.greenBright('✓ ' + success)) if (testFail.length == 1) { log('Lines in error', chalk.redBright(lines)) const stack = stackParser(testFail[0].error.stack) log(stack.diff) } } } return report } export { linereporter }