UNPKG

poku

Version:

🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.

49 lines (48 loc) 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.classic = void 0; const reporter_js_1 = require("../../builders/reporter.js"); const indentation_js_1 = require("../../configs/indentation.js"); const format_js_1 = require("../format.js"); const write_js_1 = require("../write.js"); const poku_js_1 = require("./poku.js"); exports.classic = (() => { const files = { passed: new Map(), failed: new Map(), }; return (0, reporter_js_1.createReporter)({ onRunStart() { (0, write_js_1.hr)(); (0, write_js_1.log)(`${(0, format_js_1.format)('Running Tests').bold()}\n`); }, onFileStart() { }, onFileResult({ status, path, duration, output }) { if (status) files.passed.set(path.relative, duration); else files.failed.set(path.relative, duration); if (output) (0, write_js_1.log)(output); }, onRunResult() { (0, write_js_1.hr)(); if (files.passed.size > 0 && files.failed.size === 0) { (0, write_js_1.log)(Array.from(files.passed) .map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('✔').success()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`› ${time.toFixed(6)}ms`).success()}`).dim()}`) .join('\n')); return; } if (files.failed.size > 0) { (0, write_js_1.log)(Array.from(files.failed) .map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('✘').fail()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`› ${time.toFixed(6)}ms`).fail()}`).dim()}`) .join('\n')); } }, onExit(options) { const { code } = options; poku_js_1.poku.onExit(options); (0, write_js_1.log)(`${(0, format_js_1.format)('Exited with code').dim()} ${(0, format_js_1.format)(String(code)).bold()[code === 0 ? 'success' : 'fail']()}\n`); }, }); })();