api-tests-coverage 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.js +41 -4
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -1423,11 +1423,48 @@ program
|
|
|
1423
1423
|
console.log(' Exported: generated-integration-flows.yaml');
|
|
1424
1424
|
}
|
|
1425
1425
|
}
|
|
1426
|
-
// ── 4.
|
|
1426
|
+
// ── 4. Endpoint coverage analysis → coverage-summary.json ─────────────
|
|
1427
|
+
const allCoverageResults = [];
|
|
1428
|
+
if (artifacts.specs.length > 0) {
|
|
1429
|
+
const testsGlob = artifacts.testFiles.length > 0
|
|
1430
|
+
? '{' + artifacts.testFiles.join(',') + '}'
|
|
1431
|
+
: path.join(rootDir, '**', '*');
|
|
1432
|
+
const detectedLanguages = artifacts.languages;
|
|
1433
|
+
for (const specPath of artifacts.specs) {
|
|
1434
|
+
try {
|
|
1435
|
+
console.log(`\nAnalyzing endpoint coverage for: ${path.basename(specPath)}`);
|
|
1436
|
+
const endpoints = await (0, endpointCoverage_1.parseOpenApiSpec)(specPath);
|
|
1437
|
+
const coverageMap = await (0, endpointCoverage_1.analyzeTestCoverage)(endpoints, testsGlob, detectedLanguages);
|
|
1438
|
+
const report = (0, endpointCoverage_1.buildCoverageReport)(coverageMap);
|
|
1439
|
+
const result = {
|
|
1440
|
+
type: 'endpoint',
|
|
1441
|
+
totalItems: report.total,
|
|
1442
|
+
coveredItems: report.covered,
|
|
1443
|
+
coveragePercent: report.percentage,
|
|
1444
|
+
details: report,
|
|
1445
|
+
};
|
|
1446
|
+
allCoverageResults.push(result);
|
|
1447
|
+
console.log(` ${report.covered}/${report.total} endpoints covered (${report.percentage}%)`);
|
|
1448
|
+
}
|
|
1449
|
+
catch (err) {
|
|
1450
|
+
warnings.push(`Endpoint coverage failed for ${path.basename(specPath)}: ` +
|
|
1451
|
+
`${err instanceof Error ? err.message : String(err)}`);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
if (allCoverageResults.length > 0) {
|
|
1455
|
+
const observabilityInfo = (0, observability_1.buildObservabilityInfo)(metricsPort);
|
|
1456
|
+
(0, reporting_1.generateMultiFormatReports)(allCoverageResults, ['json'], reportsDir, {}, observabilityInfo);
|
|
1457
|
+
console.log(`\nReports written to: ${reportsDir}`);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
else {
|
|
1461
|
+
warnings.push('No API spec files found; endpoint coverage analysis skipped.');
|
|
1462
|
+
}
|
|
1463
|
+
// ── 5. Emit warnings ───────────────────────────────────────────────────
|
|
1427
1464
|
for (const w of warnings) {
|
|
1428
1465
|
console.warn(`[WARN] ${w}`);
|
|
1429
1466
|
}
|
|
1430
|
-
// ──
|
|
1467
|
+
// ── 6. Configuration override log ──────────────────────────────────────
|
|
1431
1468
|
if (options['inferBusinessRules'] === false) {
|
|
1432
1469
|
console.log('\nConfiguration override detected: business rule inference disabled via CLI');
|
|
1433
1470
|
}
|
|
@@ -1435,8 +1472,8 @@ program
|
|
|
1435
1472
|
console.log('\nConfiguration override detected: integration flow inference disabled via CLI');
|
|
1436
1473
|
}
|
|
1437
1474
|
logger.info({ event: 'analyze_complete', warnings: warnings.length }, 'Agnostic project analysis complete');
|
|
1438
|
-
await finaliseObservability(
|
|
1439
|
-
// ──
|
|
1475
|
+
await finaliseObservability(allCoverageResults, {}, metricsPort, serviceName);
|
|
1476
|
+
// ── 7. Optionally launch the dashboard ─────────────────────────────────
|
|
1440
1477
|
if (options['dashboard']) {
|
|
1441
1478
|
(0, serveDashboard_1.serveDashboard)({
|
|
1442
1479
|
reportsDir: reportsDir,
|
package/package.json
CHANGED