MCPcopy Index your code
hub / github.com/nodejs/node / tapReporter

Function tapReporter

lib/internal/test_runner/reporter/tap.js:31–76  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

29
30
31async function * tapReporter(source) {
32 yield `TAP version ${kDefaultTAPVersion}\n`;
33 for await (const { type, data } of source) {
34 switch (type) {
35 case 'test:fail': {
36 yield reportTest(data.nesting, data.testNumber, 'not ok', data.name, data.skip, data.todo, data.expectFailure);
37 const location = data.file ? `${data.file}:${data.line}:${data.column}` : null;
38 yield reportDetails(data.nesting, data.details, location);
39 break;
40 } case 'test:pass':
41 yield reportTest(data.nesting, data.testNumber, 'ok', data.name, data.skip, data.todo, data.expectFailure);
42 yield reportDetails(data.nesting, data.details, null);
43 break;
44 case 'test:plan':
45 yield `${indent(data.nesting)}1..${data.count}\n`;
46 break;
47 case 'test:start':
48 yield `${indent(data.nesting)}# Subtest: ${tapEscape(data.name)}\n`;
49 break;
50 case 'test:stderr':
51 case 'test:stdout': {
52 const lines = RegExpPrototypeSymbolSplit(kLineBreakRegExp, data.message);
53 for (let i = 0; i < lines.length; i++) {
54 if (lines[i].length === 0) continue;
55 yield `# ${tapEscape(lines[i])}\n`;
56 }
57 break;
58 } case 'test:diagnostic':
59 yield `${indent(data.nesting)}# ${tapEscape(data.message)}\n`;
60 break;
61 case 'test:coverage':
62 yield getCoverageReport(indent(data.nesting), data.summary, '# ', '', true);
63 break;
64 case 'test:interrupted':
65 for (let i = 0; i < data.tests.length; i++) {
66 const test = data.tests[i];
67 let msg = `Interrupted while running: ${test.name}`;
68 if (test.file) {
69 msg += ` at ${test.file}:${test.line}:${test.column}`;
70 }
71 yield `# ${tapEscape(msg)}\n`;
72 }
73 break;
74 }
75 }
76}
77
78function reportTest(nesting, testNumber, status, name, skip, todo, expectFailure) {
79 let line = `${indent(nesting)}${status} ${testNumber}`;

Callers

nothing calls this directly

Calls 5

reportTestFunction · 0.85
reportDetailsFunction · 0.85
tapEscapeFunction · 0.85
getCoverageReportFunction · 0.85
indentFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…