mo3ta-coverage
v1.0.9
Published
Run tests and report uncovered changed lines in a PR
Maintainers
Readme
mo3ta-coverage
mo3ta-coverage is a CLI tool for checking test coverage of changed lines in a pull request. It runs related tests, parses coverage reports, and ensures cumulative coverage meets a specified threshold—ideal for CI and code review workflows.
Features
- Detects changed files between branches using
git diff - Runs related Jest tests for changed files
- Parses
lcov.infofor coverage data - Reports uncovered changed lines
- Optionally displays covered changed lines
- Checks overall coverage against a user-defined limit
Usage
mo3ta-coverage --base origin/master --lcov coverage/lcov.info --limit 80 --showCovered --shallowTests=falseCLI Options
| Option | Description | Default |
|------------------|------------------------------------------------------------------|----------------------|
| --base | Base branch to compare against | origin/main |
| --lcov | Path to lcov.info file generated by test coverage tools | coverage/lcov.info |
| --limit | Minimum required coverage percentage for all changed lines | 80 |
| --showCovered | Show covered changed lines in the output | false |
| --shallowTests | Run test files only, skipping other files | true |
How It Works
- Parse CLI options using commander in
index.js. - Get changed files: Uses
git diff --name-only <base>to find modified JS/TS files (src/cli.js). - Run related tests: Executes Jest for changed files with
--findRelatedTests(src/cli.js). - Parse coverage: Reads
lcov.infoto find uncovered lines (src/cli.js). - Report: Prints uncovered changed lines, optionally covered lines, and overall coverage (
src/cli.js). - Enforce limit: Exits with error if coverage is below the specified threshold.
mo3ta-coverage
Run tests and report uncovered changed lines in a PR. Checks cumulative coverage for all changed lines against a specified limit. Useful for CI and code review workflows.
Installation
npm install -g mo3ta-coverageUsage
mo3ta-coverage --base origin/main --lcov coverage/lcov.info --limit 80 --showCovered --shallowTestsOptions
--base <branch>: Base branch to compare against (default: origin/main or config value)--lcov <path>: Path to lcov.info file generated by test coverage tools (default: coverage/lcov.info)--limit <percent>: Minimum required coverage percentage for all changed lines (default: 80)--showCovered: Show covered changed lines in the output--shallowTests: Run test files only without deep in tests tree
Configuration
You can persist default options using the config command:
mo3ta-coverage config --base origin/dev --shallowTests falseThis will save your preferences in .mo3ta-coverage.json in your project root. The CLI will use these values unless overridden by command-line options.
Development
- Clone the repository
- Install dependencies:
npm install - Run tests:
npm test - Run tests with coverage:
npm run test:coverage
License
MIT
