MCPcopy
hub / github.com/rpamis/comet / parseTestOutput

Function parseTestOutput

scripts/context-execution-benchmark.mjs:436–470  ·  view source on GitHub ↗
(stdout)

Source from the content-addressed store, hash-verified

434}
435
436export function parseTestOutput(stdout) {
437 try {
438 const data = JSON.parse(stdout);
439 // Use top-level summary when available (Vitest JSON reporter)
440 if (typeof data.numTotalTests === 'number') {
441 const passed = data.numPassedTests ?? 0;
442 const failedNames = [];
443 for (const suite of data.testResults ?? []) {
444 for (const assertion of suite.assertionResults ?? []) {
445 if (assertion.status === 'failed') {
446 failedNames.push(assertion.fullName ?? assertion.name ?? 'unknown');
447 }
448 }
449 }
450 return {
451 testsTotal: data.numTotalTests,
452 testsPassed: passed,
453 testsFailed: failedNames,
454 testPassRate: safeRatio(passed, data.numTotalTests),
455 };
456 }
457 } catch { /* not JSON */ }
458
459 const passMatch = stdout.match(/(\d+) passed/);
460 const failMatch = stdout.match(/(\d+) failed/);
461 const testsPassed = passMatch ? Number(passMatch[1]) : 0;
462 const testsFailedCount = failMatch ? Number(failMatch[1]) : 0;
463 const total = testsPassed + testsFailedCount;
464 return {
465 testsTotal: total,
466 testsPassed,
467 testsFailed: testsFailedCount > 0 ? [`${testsFailedCount} test(s) failed`] : [],
468 testPassRate: safeRatio(testsPassed, total),
469 };
470}
471
472async function runTests(cwd) {
473 try {

Callers 2

runTestsFunction · 0.85

Calls 1

safeRatioFunction · 0.90

Tested by

no test coverage detected