| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- const fs = require('fs');
- const r = JSON.parse(fs.readFileSync('./test-results/results.json', 'utf8'));
- const stats = { passed: 0, failed: 0, skipped: 0, timedOut: 0, interrupted: 0, total: 0, other: 0 };
- const failedTests = [];
- const allTests = [];
- function walk(suite, parentFile) {
- const file = suite.file || parentFile;
- for (const sub of (suite.suites || [])) walk(sub, file);
- for (const spec of (suite.specs || [])) {
- for (const t of (spec.tests || [])) {
- stats.total++;
- const r0 = t.results && t.results[0];
- const realStatus = r0 ? r0.status : t.status;
- if (realStatus === 'passed') stats.passed++;
- else if (realStatus === 'skipped') stats.skipped++;
- else if (realStatus === 'timedOut') stats.timedOut++;
- else if (realStatus === 'failed') {
- stats.failed++;
- failedTests.push({
- file: file ? file.replace(/\\/g, '/').split('/tests/').pop() : '',
- title: spec.title,
- status: realStatus,
- error: r0 && r0.error ? (r0.error.message || '').split('\n')[0].slice(0, 200) : ''
- });
- } else if (realStatus === 'interrupted') stats.interrupted++;
- else stats.other++;
- allTests.push({
- file: file ? file.replace(/\\/g, '/').split('/tests/').pop() : '',
- title: spec.title,
- status: realStatus
- });
- }
- }
- }
- for (const s of (r.suites || [])) walk(s, '');
- console.log('SUMMARY:');
- console.log(JSON.stringify(stats, null, 2));
- console.log('\nFAILED TESTS:');
- console.log(JSON.stringify(failedTests, null, 2));
- console.log('\nALL TESTS BY STATUS:');
- const byStatus = {};
- for (const t of allTests) {
- byStatus[t.status] = (byStatus[t.status] || 0) + 1;
- }
- console.log(JSON.stringify(byStatus, null, 2));
|