UNPKG

@tapjs/reporter

Version:

Pretty test output reporters for tap

29 lines 1.28 kB
import { Text } from 'ink'; import React from 'react'; export const TestBadge = ({ test }) => { const { results, counts, options, bailedOut } = test; const { exitCode, signal, failSkip, failTodo } = options; if (!results) { return (React.createElement(Text, { backgroundColor: "yellow", color: "#000", bold: true }, ' RUNS ')); } const { ok, skip: resultsSkip, plan } = results; // we don't get these things on a bailout const { skipAll } = plan || {}; const { fail, todo, skip } = counts || {}; const isSkip = !!skip || skipAll || !!resultsSkip; const isFail = !ok || !!fail || signal || bailedOut || exitCode || (!!todo && failTodo) || (isSkip && failSkip); return (isFail ? React.createElement(Text, { backgroundColor: "red", color: "#fff", bold: true }, ' FAIL ') : !!todo ? React.createElement(Text, { backgroundColor: "#808", color: "#fff", bold: true }, ' TODO ') : isSkip ? React.createElement(Text, { backgroundColor: "blue", color: "#fff", bold: true }, ' SKIP ') : React.createElement(Text, { backgroundColor: "#0a0", color: "#000", bold: true }, ' PASS ')); }; //# sourceMappingURL=test-badge.js.map