foundations/server/common/scripts/README.md
This directory contains Node.js scripts for managing code coverage in the huly.server monorepo.
merge-coverage.jsMerges individual package coverage reports into a single LCOV file.
Usage:
node merge-coverage.js
What it does:
packages/, pods/, and tests/ directories for coverage reportscoverage/lcov.info filescoverage/lcov.info at the rootOutput:
coverage/lcov.info - Merged coverage datagenerate-coverage-html.jsGenerates HTML coverage reports from LCOV data.
Usage:
node generate-coverage-html.js [input-lcov-file] [output-directory]
Default usage:
node generate-coverage-html.js coverage/lcov.info coverage/html
What it does:
Output:
coverage/html/index.html - Main coverage reportcoverage/html/**/*.html - Per-file coverage reportsDependencies:
lcov-parse - Parses LCOV formatistanbul-lib-coverage - Coverage map managementistanbul-lib-report - Report contextistanbul-reports - HTML report generationshow-coverage-summary.jsDisplays a summary of coverage statistics by package.
Usage:
node show-coverage-summary.js [lcov-file]
Default usage:
node show-coverage-summary.js coverage/lcov.info
What it does:
Example Output:
==============================================
COVERAGE SUMMARY BY PACKAGE
==============================================
Package Covered Total Coverage
----------------------------------------------
datalake 10 10 100.00%
minio 111 165 67.27%
postgres 815 1351 60.33%
...
----------------------------------------------
TOTAL 1156 2220 52.07%
run-tests-with-coverage.jsRuns tests with coverage for all packages sequentially.
Usage:
node run-tests-with-coverage.js
What it does:
packages/ directorynpm test -- --coverage --silentNote: This is an alternative to rush test for running tests individually.
The package.json in this directory provides convenient aliases:
# Merge coverage reports
npm run coverage:merge
# Generate HTML report
npm run coverage:html
# Show coverage summary
npm run coverage:summary
# Run all package tests with coverage
npm run test:coverage
# Run all tests with coverage and generate reports
rush coverage
This command does:
rush test - Runs all package tests (coverage enabled by jest.config.js)node scripts/merge-coverage.js - Merges all LCOV filesnode scripts/generate-coverage-html.js - Generates HTML report# 1. Run tests with coverage (coverage enabled in jest.config.js)
rush test
# 2. Merge coverage reports
node common/scripts/merge-coverage.js
# 3. Generate HTML report
node common/scripts/generate-coverage-html.js coverage/lcov.info coverage/html
# 4. View summary
node common/scripts/show-coverage-summary.js
All packages have coverage enabled by default in jest.config.js:
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
roots: ['./src'],
collectCoverage: true, // ✅ Enabled by default
coverageReporters: ['text-summary', 'html', 'lcov'], // ✅ LCOV format
coverageDirectory: 'coverage' // ✅ Output directory
}
coverage/
├── lcov.info # Merged LCOV coverage data
└── html/ # HTML reports
├── index.html # Main report page
├── base.css # Styling
├── prettify.js # Code highlighting
└── [package]/ # Per-package reports
└── [file].html # Per-file coverage
packages/
└── [package-name]/
└── coverage/
├── lcov.info # Package-specific LCOV
└── html/ # Package-specific HTML
Current overall coverage: 52.07%
Per-package targets:
Error: No lcov files found in packages/pods/tests/*/coverage/lcov.info
Solution: Run tests first with rush test to generate coverage files.
Error: Cannot find module 'lcov-parse'
Solution:
cd common/scripts
npm install
The scripts attempt to resolve source file paths using multiple strategies:
If files still can't be found, check that source files exist and paths in LCOV are correct.
The following bash scripts have been replaced with Node.js versions:
show-coverage.sh → ✅ run-tests-with-coverage.jsshow-coverage-summary.sh → ✅ show-coverage-summary.jsThe bash scripts are kept for backward compatibility but the Node.js versions are recommended for better cross-platform support.
The LCOV format is compatible with common coverage tools:
bash <(curl -s https://codecov.io/bash)cat coverage/lcov.info | coverallssonar.javascript.lcov.reportPaths=coverage/lcov.info