@idirdev/covercheck
v1.0.0
Published
Check code coverage against thresholds
Downloads
19
Readme
covercheck
[EN] Parse LCOV coverage reports and enforce line, branch, and function coverage thresholds — fail CI when coverage drops below your standards. [FR] Analysez les rapports de couverture LCOV et appliquez des seuils de couverture pour les lignes, branches et fonctions — faites échouer CI quand la couverture descend sous vos standards.
Features / Fonctionnalités
[EN]
- Parses standard
lcov.infofiles generated by Jest, Istanbul, c8, and others - Reports line, branch, and function coverage percentages per project
- Configurable threshold (default 80%) via
--threshold - Auto-detects
coverage/lcov.infoorlcov.infoin the working directory - Custom file path via
--filefor non-standard output locations - Exits with code 1 on threshold failure — integrates cleanly with GitHub Actions
- Zero external dependencies
[FR]
- Analyse les fichiers
lcov.infostandard générés par Jest, Istanbul, c8, etc. - Affiche les pourcentages de couverture ligne, branche et fonction par projet
- Seuil configurable (80% par défaut) via
--threshold - Détection automatique de
coverage/lcov.infooulcov.infodans le répertoire courant - Chemin de fichier personnalisé via
--filepour les emplacements non standard - Quitte avec le code 1 en cas d'échec de seuil — intégration facile avec GitHub Actions
- Aucune dépendance externe
Installation
npm install -g @idirdev/covercheckCLI Usage / Utilisation CLI
# Check coverage using auto-detected lcov.info
# Vérifier la couverture avec détection automatique de lcov.info
covercheck
# Specify a custom coverage file
# Spécifier un fichier de couverture personnalisé
covercheck --file ./coverage/lcov.info
# Set a custom threshold (90%)
# Définir un seuil personnalisé (90%)
covercheck --threshold 90
# Combine: custom file + strict 95% threshold
# Combiner : fichier personnalisé + seuil strict 95%
covercheck --file ./coverage/lcov.info --threshold 95
# Use in CI — exits 1 if coverage is insufficient
# Utiliser en CI — quitte avec 1 si la couverture est insuffisante
covercheck --threshold 80 || exit 1Example Output / Exemple de sortie
Coverage (24 files):
Lines: 87.42%
Branches: 76.15%
Functions: 91.30%
Threshold failures:
Branches: 76.15% < 80%API (Programmatic) / API (Programmation)
const fs = require('fs');
const {
parseLcov,
summarize,
checkThresholds,
findCoverageFile,
calcPercentage
} = require('@idirdev/covercheck');
// Auto-find the lcov.info file in a project
// Trouver automatiquement le fichier lcov.info dans un projet
const filePath = findCoverageFile('./my-project');
// => './my-project/coverage/lcov.info' or null
// Parse LCOV content into a per-file structure
// Analyser le contenu LCOV en structure par fichier
const content = fs.readFileSync(filePath, 'utf8');
const files = parseLcov(content);
// => { 'src/index.js': { lines: { found: 100, hit: 87 }, branches: {...}, functions: {...} }, ... }
// Summarize into overall percentages
// Résumer en pourcentages globaux
const summary = summarize(files);
// => { lines: 87.42, branches: 76.15, functions: 91.3, fileCount: 24 }
// Check against thresholds
// Vérifier par rapport aux seuils
const result = checkThresholds(summary, { lines: 80, branches: 80, functions: 80 });
// => { ok: false, failures: ['Branches: 76.15% < 80%'] }
// Calculate a single percentage
// Calculer un seul pourcentage
calcPercentage(87, 100); // => 87
calcPercentage(0, 0); // => 100 (no lines = fully covered)License
MIT © idirdev
