poku
Version:
🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.
33 lines (32 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parserOutput = void 0;
const poku_js_1 = require("../configs/poku.js");
const regex = {
ansi: /u001b\[0m|\n/i,
skip: /\\u001b\[94m\\u001b\[1m◯/gi,
todo: /\\u001b\[96m\\u001b\[1m●/gi,
};
const parserOutput = (options) => {
const { output, result } = options;
const normalizedOutput = JSON.stringify(output);
const hasSkip = normalizedOutput.match(regex.skip);
if (hasSkip)
poku_js_1.results.skipped += hasSkip.length;
const hasTodo = normalizedOutput.match(regex.todo);
if (hasTodo)
poku_js_1.results.todo += hasTodo.length;
const pad = ' ';
const splittedOutput = output.split('\n');
const outputs = (poku_js_1.GLOBAL.configs.debug || !result
? splittedOutput
: splittedOutput.filter((current) => {
if (current.indexOf('Exited with code') !== -1)
return false;
return regex.ansi.test(JSON.stringify(current)) || current === '';
})).filter((line) => line?.trim().length > 0);
if (outputs.length === 0)
return;
return outputs.map((current) => `${pad}${current}`);
};
exports.parserOutput = parserOutput;