@tapjs/reporter
Version:
Pretty test output reporters for tap
23 lines • 1.09 kB
JavaScript
import { Box, Text } from 'ink';
import React, { useLayoutEffect, useState } from 'react';
import { listenCleanup } from './listen-cleanup.js';
import { ResultDetailList } from './result-detail-list.js';
const getColor = (r) => r.skip ? 'cyan'
: r.todo ? 'magenta'
: !r.ok ? 'red'
: 'green';
const DOTS = [];
const Dots = ({ test }) => {
const [dots, updateDots] = useState([]);
useLayoutEffect(() => listenCleanup(test, 'assert', r => {
DOTS.push(getColor(r));
updateDots([...DOTS]);
}), [dots]);
const width = Math.max(15, columns);
return (React.createElement(Box, { width: width, flexWrap: "wrap" }, dots.map((c, i) => (React.createElement(Text, { key: i, color: c }, ".")))));
};
const { columns = 70 } = process.stdout;
export const Dot = ({ test }) => (React.createElement(Box, { flexDirection: "column" },
React.createElement(Dots, { test: test }),
React.createElement(ResultDetailList, { test: test, filter: ({ parser, counts }) => !parser.ok || !!counts.todo || !!counts.fail })));
//# sourceMappingURL=dot.js.map