Skip to main content
Glama
check-coverage.js1.36 kB
#!/usr/bin/env node import fs from 'fs'; import path from 'path'; /** * Check if test coverage meets the required thresholds */ function checkCoverage() { const coveragePath = path.join(process.cwd(), 'coverage', 'coverage-summary.json'); if (!fs.existsSync(coveragePath)) { console.error('❌ Coverage summary not found. Run tests with coverage first.'); process.exit(1); } const coverage = JSON.parse(fs.readFileSync(coveragePath, 'utf8')); const total = coverage.total; // Define thresholds (matching jest.config.js) const thresholds = { statements: 89, branches: 76, functions: 92, lines: 89 }; let passed = true; const results = []; for (const [metric, threshold] of Object.entries(thresholds)) { const actual = total[metric].pct; const status = actual >= threshold ? '✅' : '❌'; if (actual < threshold) { passed = false; } results.push(`${status} ${metric}: ${actual}% (required: ${threshold}%)`); } console.log('\n📊 Coverage Report:'); console.log('=================='); results.forEach(result => console.log(result)); if (passed) { console.log('\n🎉 All coverage thresholds met!'); process.exit(0); } else { console.log('\n💥 Coverage thresholds not met. Please add more tests.'); process.exit(1); } } checkCoverage();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/keyurgolani/ColorMcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server