UNPKG

@supertape/formatter-json-lines

Version:

📼Supertape formatter progress bar

63 lines (49 loc) • 1.14 kB
import {fullstore} from 'fullstore'; const out = createOutput(); const store = fullstore(); export const test = ({test}) => { store(test); }; const stringify = (a) => JSON.stringify(a) + '\n'; export const testEnd = ({count, total, failed, test}) => { return stringify({ count, total, failed, test, }); }; export const fail = ({at, count, message, operator, result, expected, output, errorStack}) => { return out({ test: store(), at, count, message, operator, result, expected, errorStack, output, }); }; export const end = ({count, passed, failed, skipped}) => { out({ count, passed, failed, skipped, }); return out(); }; function createOutput() { let output = []; return (...args) => { const [line] = args; if (!args.length) { const result = output.join(''); output = []; return result; } output.push(stringify(line)); }; }