-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-test-json.js
More file actions
executable file
·42 lines (37 loc) · 1.15 KB
/
parse-test-json.js
File metadata and controls
executable file
·42 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
// Parse vitest JSON reporter output
const fs = require('fs');
// Read from stdin
let data = '';
process.stdin.on('data', chunk => {
data += chunk;
});
process.stdin.on('end', () => {
try {
const json = JSON.parse(data);
console.log('Test Results:');
console.log('=============');
console.log(`Total Tests: ${json.numTotalTests}`);
console.log(`Passed: ${json.numPassedTests}`);
console.log(`Failed: ${json.numFailedTests}`);
console.log(`Pending: ${json.numPendingTests}`);
if (json.numTotalTests > 0) {
const passRate = (json.numPassedTests / json.numTotalTests * 100).toFixed(2);
console.log(`Pass Rate: ${passRate}%`);
}
// Show failures if any
if (json.numFailedTests > 0) {
console.log('\nFailed Tests:');
json.testResults.forEach(suite => {
suite.assertionResults
.filter(test => test.status === 'failed')
.forEach(test => {
console.log(` ✗ ${test.fullName}`);
});
});
}
} catch (e) {
console.error('Failed to parse JSON:', e.message);
console.error('Raw data:', data.substring(0, 200));
}
});