mo3ta-coverage 1.0.12 → 1.0.13

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/README.md CHANGED
@@ -4,11 +4,13 @@ mo3ta-coverage checks coverage for changed lines in a pull request. It finds cha
4
4
 
5
5
  ## Features
6
6
 
7
- - Detects changed JS/TS files from git history and working tree
7
+ - Detects changed JS/TS files from all commits in the current branch, uncommitted changes, and staged files
8
8
  - Maps changed source files to nearby test files automatically
9
9
  - Supports three execution modes: `fast`, `smart`, and `full`
10
+ - Smart mode includes reverse dependency analysis with configurable depth
10
11
  - Parses `lcov.info` and reports uncovered changed lines
11
12
  - Enforces a minimum coverage threshold for changed lines
13
+ - Helpful error messages when invalid options are provided
12
14
 
13
15
  ## Installation
14
16
 
@@ -26,17 +28,21 @@ mo3ta-coverage --mode smart --base origin/main --limit 80
26
28
 
27
29
  | Option | Description | Default |
28
30
  |--------|-------------|---------|
31
+ | `-v, --version` | Output the current version | - |
29
32
  | `--base <branch>` | Base branch to compare against | `origin/main` |
30
33
  | `--lcov <path>` | Path to `lcov.info` | `coverage/lcov.info` |
31
34
  | `--limit <percent>` | Minimum changed-line coverage percentage | `80` |
32
35
  | `--showCovered <bool>` | Show covered changed lines in output | `false` |
33
- | `--mode <mode>` | Execution mode: `fast`, `smart`, or `full` | `smart` |
36
+ | `--mode <mode>` | Execution mode: `fast`, `smart`, or `full` (required) | `smart` |
37
+ | `--maxDepth <number>` | Maximum reverse dependency depth for smart mode | `3` |
34
38
 
35
39
  ## Modes
36
40
 
37
- - `fast`: Direct execution of mapped test files only. No Jest dependency traversal.
38
- - `smart`: Direct execution of changed source files plus mapped test files. No Jest dependency traversal.
39
- - `full`: Runs mapped test files through `jest --findRelatedTests`.
41
+ - **`fast`**: Direct execution of mapped test files only. No Jest dependency traversal. Fastest option.
42
+ - **`smart`**: Direct execution of changed source files plus mapped test files, with reverse dependency analysis. Includes tests for files that import your changes up to `--maxDepth` levels. Recommended for most projects.
43
+ - **`full`**: Runs mapped test files through `jest --findRelatedTests`. Let Jest expand to related tests. Use with caution in large projects.
44
+
45
+ If an invalid mode is provided, the tool will display available options with descriptions.
40
46
 
41
47
  ## Recommended Mode
42
48
 
@@ -53,11 +59,20 @@ Use `full` only when you intentionally want Jest to expand to related tests.
53
59
  You can persist defaults with the `config` subcommand:
54
60
 
55
61
  ```sh
56
- mo3ta-coverage config --base origin/main --mode smart
62
+ mo3ta-coverage config --base origin/main --mode smart --maxDepth 3
57
63
  ```
58
64
 
59
65
  This writes `.mo3ta-coverage.json` in the project root.
60
66
 
67
+ ## Changed Files Detection
68
+
69
+ The tool detects changed files by comparing against the specified base branch:
70
+ - All committed files in the current branch (from merge-base to HEAD)
71
+ - Uncommitted changes in the working tree
72
+ - Staged changes (files added with `git add`)
73
+
74
+ This means coverage is checked for all changes in your branch, not just your authored commits.
75
+
61
76
  ## How It Works
62
77
 
63
78
  1. Reads CLI options and saved config from [index.js](index.js).
package/index.js CHANGED
@@ -27,7 +27,8 @@ const program = new Command();
27
27
 
28
28
  program
29
29
  .name('mo3ta-coverage')
30
- .description('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.');
30
+ .description('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.')
31
+ .version('1.0.13', '-v, --version', 'Output the current version');
31
32
 
32
33
  program
33
34
  .option('--base <branch>', 'Base branch to compare against (e.g., origin/main)')
@@ -109,9 +110,30 @@ program.action((opts) => {
109
110
  options.maxDepth = config.maxDepth;
110
111
  }
111
112
 
112
- options.mode = String(options.mode || 'smart').toLowerCase();
113
+ // Validate mode
114
+ options.mode = options.mode || 'smart'; // Default to smart if not provided
115
+
116
+ // Check if mode is invalid (boolean, empty string, etc.)
117
+ if (typeof options.mode === 'boolean' || options.mode === '') {
118
+ console.error(`❌ Missing or invalid --mode value.`);
119
+ console.error(`Available options: fast, smart, full`);
120
+ console.error(`\nMode descriptions:`);
121
+ console.error(` • fast - Direct execution of mapped test files only`);
122
+ console.error(` • smart - Combine source and mapped test files with reverse deps (recommended)`);
123
+ console.error(` • full - Run mapped tests through Jest --findRelatedTests`);
124
+ console.error(`\nExample: mo3ta-coverage --mode smart`);
125
+ process.exit(1);
126
+ }
127
+
128
+ options.mode = String(options.mode).toLowerCase();
113
129
  if (!['fast', 'smart', 'full'].includes(options.mode)) {
114
- console.error(`Invalid mode: ${options.mode}. Expected one of: fast, smart, full.`);
130
+ console.error(`❌ Invalid mode: "${options.mode}"`);
131
+ console.error(`Available options: fast, smart, full`);
132
+ console.error(`\nMode descriptions:`);
133
+ console.error(` • fast - Direct execution of mapped test files only`);
134
+ console.error(` • smart - Combine source and mapped test files with reverse deps (recommended)`);
135
+ console.error(` • full - Run mapped tests through Jest --findRelatedTests`);
136
+ console.error(`\nExample: mo3ta-coverage --mode smart`);
115
137
  process.exit(1);
116
138
  }
117
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mo3ta-coverage",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Run tests and report uncovered changed lines in a PR",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -69,7 +69,7 @@ function getChangedFiles(BASE_BRANCH) {
69
69
  verifyBaseBranchExists(BASE_BRANCH);
70
70
 
71
71
  const command = `(
72
- git log --pretty=format: --name-only --diff-filter=AM --author="$(git config user.name)" $(git merge-base HEAD ${BASE_BRANCH})..HEAD
72
+ git log --pretty=format: --name-only --diff-filter=AM $(git merge-base HEAD ${BASE_BRANCH})..HEAD
73
73
  git diff --name-only --diff-filter=AM
74
74
  git diff --cached --name-only --diff-filter=AM
75
75
  ) | sort -u`;