UNPKG

tehanu-repo-coco

Version:

Reports the test progress of tests written with tehanu on the console with colours if the terminal supports them.

73 lines (56 loc) 1.38 kB
'use strict'; const { env, stdout } = process, enabled = !('NO_COLOR' in env) && ('FORCE_COLOR' in env || stdout.isTTY && (process.platform === 'win32' || env.TERM !== "dumb")), color = number => enabled ? msg => stdout.write(`\u001b[${number}m${msg}\u001b[39m`) : msg => stdout.write(msg); // const black = color(30) const red = color(31); const green = color(32); const yellow = color(33); // const blue = color(34) const magenta = color(35); const cyan = color(36); // const white = color(37) const gray = color(90); const printError = err => { const { stack } = err; const eol = stack.indexOf('\n') + 1; yellow(stack.slice(0, eol)); gray(`${stack.slice(eol)} `); }; let count, failed; function start() {} function startSuite(name, { length }) { count = length; failed = 0; cyan(`${name} `); } function ok() { gray('•'); } function fail({ name }, err) { ++failed; red(` Failed: ${name} `); printError(err); } function bail() {} function skip() {} function endSuite() { if (failed) magenta(` ✘ ${failed} of ${count} `); else green(` ✔ ${count} `); } function end() {} exports.bail = bail; exports.end = end; exports.endSuite = endSuite; exports.fail = fail; exports.ok = ok; exports.skip = skip; exports.start = start; exports.startSuite = startSuite; //# sourceMappingURL=index.cjs.map