metaltest/reporter/endreporter.js

18 lines
583 B
JavaScript

import chalk from 'chalk'
import { log } from '../lib/log.js'
const percentage = (dividend, divisor) => (dividend / divisor * 100).toFixed(0)
const endreporter = () => {
let success = 0, fail = 0, skip = 0
return {
success: (test) => { success++ },
fail: (test, e) => { fail++ },
skip: (test) => { skip++ },
end: (stats) => { log(`${chalk.redBright(`Fail: ${fail}`)} - ${chalk.greenBright(`Sucess: ${success}`)} - ${chalk.blueBright(`Skip: ${skip}`)} - ${chalk.yellowBright(`Ratio: ${percentage(success, success + fail)}%`)}`) },
}
}
export { endreporter }