MCPcopy
hub / github.com/Doorman11991/smallcode / parseJest

Function parseJest

src/tools/run_tests.js:123–142  ·  view source on GitHub ↗
(output)

Source from the content-addressed store, hash-verified

121}
122
123function parseJest(output) {
124 const result = { passed: 0, failed: 0, errors: 0, skipped: 0, failures: [] };
125
126 // "Tests: 1 failed, 2 passed, 3 total" or "Tests: 3 passed, 3 total"
127 const testsLine = output.split('\n').find(l => /^Tests:/i.test(l.trim()));
128 if (testsLine) {
129 const p = testsLine.match(/(\d+) passed/); if (p) result.passed = parseInt(p[1], 10);
130 const f = testsLine.match(/(\d+) failed/); if (f) result.failed = parseInt(f[1], 10);
131 const s = testsLine.match(/(\d+) skipped/); if (s) result.skipped = parseInt(s[1], 10);
132 }
133
134 // "● test suite › test name" failure headers
135 const failHeaderRe = /^\s*●\s+(.+)$/mg;
136 let m;
137 while ((m = failHeaderRe.exec(output)) !== null) {
138 result.failures.push({ name: m[1].trim(), message: '' });
139 }
140
141 return result;
142}
143
144function parseVitest(output) {
145 const result = { passed: 0, failed: 0, errors: 0, skipped: 0, failures: [] };

Callers 2

run_tests.test.jsFile · 0.85
parseOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected