UNPKG

@tapjs/reporter

Version:
36 lines 2.08 kB
// The <Static> section that appends results as the tests run // Each log entry can be one of: // - A finished test // - A failed Result object (on the root test) // - a stderr or stdout message import { Box, Static, Text } from 'ink'; import React from 'react'; import { isConsoleLog, isStdioLog, isTestLog, useLog, } from './hooks/use-log.js'; import { TestSummary } from './test-summary.js'; export const TestLogLine = ({ test, previous }) => (React.createElement(Box, { paddingTop: !!previous && !isTestLog(previous) ? 1 : 0 }, React.createElement(TestSummary, { test: test }))); export const ConsoleLogLine = ({ text, previous }) => (React.createElement(Box, { paddingTop: !!previous && !isConsoleLog(previous) ? 1 : 0 }, React.createElement(Text, null, text.trimEnd()))); export const StdioLogLine = ({ name, fd, text, previous: p, }) => { const prefix = isStdioLog(p) && p.fd === fd && p.name === name ? React.createElement(React.Fragment, null) : React.createElement(Box, { gap: 1, paddingTop: 1 }, fd === 1 ? React.createElement(Text, { color: "cyan", bold: true, dimColor: true }, `1>`) : React.createElement(Text, { color: "red", bold: true, dimColor: true }, `2>`), React.createElement(Text, { dimColor: true }, name)); return (React.createElement(Box, { flexDirection: "column" }, prefix, React.createElement(Box, null, React.createElement(Text, null, String(text).trimEnd())))); }; export const Log = ({ test, config, includeTests }) => { if (test.results) return React.createElement(React.Fragment, null); const logs = useLog(test, config, includeTests); return (React.createElement(Static, { items: logs }, (log, key) => React.createElement(LogLine, { ...log, key: key }))); }; const LogLine = log => isTestLog(log) ? React.createElement(TestLogLine, { ...log }) : isStdioLog(log) ? React.createElement(StdioLogLine, { ...log }) : React.createElement(ConsoleLogLine, { ...log }); //# sourceMappingURL=log.js.map