jest-test-lineage-reporter 2.0.1 ā 2.1.0
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 +252 -0
- package/bin/jest-lineage.js +20 -0
- package/package.json +14 -5
- package/src/MutationTester.js +1154 -0
- package/src/__tests__/assertion-test.test.ts +59 -0
- package/src/__tests__/calculator.test.ts +30 -0
- package/src/__tests__/depth-example.test.ts +237 -0
- package/src/__tests__/gc-pressure-example.test.ts +169 -0
- package/src/__tests__/performance-example.test.ts +83 -0
- package/src/__tests__/quality-example.test.ts +122 -0
- package/src/__tests__/survived-mutations-example.test.ts +32 -0
- package/src/__tests__/truly-weak-example.test.ts +90 -0
- package/src/__tests__/weak-test-example.test.ts +222 -0
- package/src/babel-plugin-mutation-tester.js +402 -0
- package/src/calculator.ts +12 -0
- package/src/cli/commands/analyze.js +91 -0
- package/src/cli/commands/mutate.js +89 -0
- package/src/cli/commands/query.js +107 -0
- package/src/cli/commands/report.js +65 -0
- package/src/cli/commands/test.js +56 -0
- package/src/cli/index.js +89 -0
- package/src/cli/utils/config-loader.js +114 -0
- package/src/cli/utils/data-loader.js +118 -0
- package/src/cli/utils/jest-runner.js +105 -0
- package/src/cli/utils/output-formatter.js +126 -0
- package/src/depth-example.ts +66 -0
- package/src/gc-pressure-example.ts +158 -0
- package/src/global.d.ts +7 -0
- package/src/mcp/server.js +469 -0
- package/src/performance-example.ts +82 -0
- package/src/quality-example.ts +79 -0
- package/src/survived-mutations-example.ts +19 -0
- package/src/truly-weak-example.ts +37 -0
- package/src/weak-test-example.ts +91 -0
package/README.md
CHANGED
|
@@ -16,6 +16,258 @@ A comprehensive test analytics platform that provides line-by-line test coverage
|
|
|
16
16
|
- **Easy integration**: Simple Jest reporter that works alongside existing reporters
|
|
17
17
|
- **TypeScript support**: Built with TypeScript support out of the box
|
|
18
18
|
- **Statistics and insights**: File-level and overall statistics about test coverage patterns
|
|
19
|
+
- **š CLI Tool**: Powerful command-line interface for standalone operations
|
|
20
|
+
|
|
21
|
+
## š CLI Usage (New!)
|
|
22
|
+
|
|
23
|
+
Jest Test Lineage Reporter now includes a powerful CLI tool!
|
|
24
|
+
|
|
25
|
+
### Quick Start with CLI
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Run tests with lineage tracking
|
|
29
|
+
jest-lineage test
|
|
30
|
+
|
|
31
|
+
# Run mutation testing on existing data
|
|
32
|
+
jest-lineage mutate --threshold 85
|
|
33
|
+
|
|
34
|
+
# Generate HTML report
|
|
35
|
+
jest-lineage report --open
|
|
36
|
+
|
|
37
|
+
# Query which tests cover a specific line
|
|
38
|
+
jest-lineage query src/calculator.ts 42
|
|
39
|
+
|
|
40
|
+
# Full analysis workflow (test + mutate + report)
|
|
41
|
+
jest-lineage analyze --open
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### CLI Commands
|
|
45
|
+
|
|
46
|
+
#### `jest-lineage test [jest-args...]`
|
|
47
|
+
Run Jest tests with lineage tracking enabled.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Basic usage
|
|
51
|
+
jest-lineage test
|
|
52
|
+
|
|
53
|
+
# Pass Jest arguments
|
|
54
|
+
jest-lineage test --watch --testPathPattern=calculator
|
|
55
|
+
|
|
56
|
+
# Disable specific features
|
|
57
|
+
jest-lineage test --no-performance --no-quality
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### `jest-lineage mutate`
|
|
61
|
+
Run mutation testing standalone (on existing lineage data).
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Basic mutation testing
|
|
65
|
+
jest-lineage mutate
|
|
66
|
+
|
|
67
|
+
# With custom threshold
|
|
68
|
+
jest-lineage mutate --threshold 90
|
|
69
|
+
|
|
70
|
+
# Debug mode (create mutation files without running tests)
|
|
71
|
+
jest-lineage mutate --debug --debug-dir ./mutations
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### `jest-lineage report`
|
|
75
|
+
Generate HTML report from existing lineage data.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Generate and open report
|
|
79
|
+
jest-lineage report --open
|
|
80
|
+
|
|
81
|
+
# Custom output path
|
|
82
|
+
jest-lineage report --output coverage-report.html
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### `jest-lineage query <file> [line]`
|
|
86
|
+
Query which tests cover specific files or lines.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Query entire file
|
|
90
|
+
jest-lineage query src/calculator.ts
|
|
91
|
+
|
|
92
|
+
# Query specific line
|
|
93
|
+
jest-lineage query src/calculator.ts 42
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `jest-lineage analyze`
|
|
97
|
+
Full workflow: run tests, mutation testing, and generate report.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Complete analysis
|
|
101
|
+
jest-lineage analyze --open
|
|
102
|
+
|
|
103
|
+
# Skip mutation testing
|
|
104
|
+
jest-lineage analyze --skip-mutation --open
|
|
105
|
+
|
|
106
|
+
# Use existing test data
|
|
107
|
+
jest-lineage analyze --skip-tests --open
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### CLI Options
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
Global Options:
|
|
114
|
+
-v, --version Show version number
|
|
115
|
+
-h, --help Show help
|
|
116
|
+
|
|
117
|
+
Test Command:
|
|
118
|
+
--config <path> Path to Jest config file
|
|
119
|
+
--no-lineage Disable lineage tracking
|
|
120
|
+
--no-performance Disable performance tracking
|
|
121
|
+
--no-quality Disable quality analysis
|
|
122
|
+
--quiet, -q Suppress console output
|
|
123
|
+
|
|
124
|
+
Mutate Command:
|
|
125
|
+
--data <path> Path to lineage data file (default: .jest-lineage-data.json)
|
|
126
|
+
--threshold <number> Mutation score threshold (default: 80)
|
|
127
|
+
--timeout <ms> Timeout per mutation (default: 5000)
|
|
128
|
+
--debug Create debug mutation files
|
|
129
|
+
--debug-dir <path> Directory for debug files (default: ./mutations-debug)
|
|
130
|
+
--verbose Enable debug logging
|
|
131
|
+
|
|
132
|
+
Report Command:
|
|
133
|
+
--data <path> Path to lineage data file
|
|
134
|
+
--output <path> Output HTML file path (default: test-lineage-report.html)
|
|
135
|
+
--open Open report in browser
|
|
136
|
+
--format <type> Report format (default: html)
|
|
137
|
+
|
|
138
|
+
Query Command:
|
|
139
|
+
--data <path> Path to lineage data file
|
|
140
|
+
--json Output as JSON
|
|
141
|
+
--format <type> Output format: table, list, json (default: table)
|
|
142
|
+
|
|
143
|
+
Analyze Command:
|
|
144
|
+
--config <path> Path to Jest config file
|
|
145
|
+
--threshold <number> Mutation score threshold (default: 80)
|
|
146
|
+
--output <path> Output HTML file path
|
|
147
|
+
--open Open report in browser
|
|
148
|
+
--skip-tests Skip running tests (use existing data)
|
|
149
|
+
--skip-mutation Skip mutation testing
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Configuration Priority
|
|
153
|
+
|
|
154
|
+
The CLI respects configuration from multiple sources with this priority:
|
|
155
|
+
|
|
156
|
+
1. **CLI Arguments** (highest priority)
|
|
157
|
+
2. **Environment Variables** (`JEST_LINEAGE_*`)
|
|
158
|
+
3. **Config File** (jest.config.js)
|
|
159
|
+
4. **package.json** (`"jest-lineage"` field)
|
|
160
|
+
5. **Defaults** (lowest priority)
|
|
161
|
+
|
|
162
|
+
Example package.json configuration:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"jest-lineage": {
|
|
167
|
+
"mutationThreshold": 85,
|
|
168
|
+
"outputFile": "test-analytics.html",
|
|
169
|
+
"enableMutationTesting": true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## š¤ MCP Server (New!)
|
|
175
|
+
|
|
176
|
+
Jest Test Lineage Reporter now includes a Model Context Protocol (MCP) server for programmatic access via AI assistants like Claude.
|
|
177
|
+
|
|
178
|
+
### What is MCP?
|
|
179
|
+
|
|
180
|
+
The Model Context Protocol allows AI assistants to interact with your test infrastructure programmatically. With the MCP server, you can ask Claude to run tests, analyze mutation scores, generate reports, and query coverage data directly.
|
|
181
|
+
|
|
182
|
+
### Setting Up the MCP Server
|
|
183
|
+
|
|
184
|
+
Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"mcpServers": {
|
|
189
|
+
"jest-test-lineage-reporter": {
|
|
190
|
+
"command": "node",
|
|
191
|
+
"args": [
|
|
192
|
+
"/path/to/your/project/node_modules/jest-test-lineage-reporter/src/mcp/server.js"
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Or if installed globally:
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"mcpServers": {
|
|
204
|
+
"jest-test-lineage-reporter": {
|
|
205
|
+
"command": "node",
|
|
206
|
+
"args": [
|
|
207
|
+
"$(npm root -g)/jest-test-lineage-reporter/src/mcp/server.js"
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Available MCP Tools
|
|
215
|
+
|
|
216
|
+
The MCP server exposes these tools:
|
|
217
|
+
|
|
218
|
+
#### `run_tests`
|
|
219
|
+
Run Jest tests with lineage tracking and generate coverage data.
|
|
220
|
+
|
|
221
|
+
**Parameters:**
|
|
222
|
+
- `args` (array): Jest command-line arguments
|
|
223
|
+
- `enableLineage` (boolean): Enable lineage tracking (default: true)
|
|
224
|
+
- `enablePerformance` (boolean): Enable performance tracking (default: true)
|
|
225
|
+
- `enableQuality` (boolean): Enable quality analysis (default: true)
|
|
226
|
+
|
|
227
|
+
#### `run_mutation_testing`
|
|
228
|
+
Run mutation testing on existing lineage data to assess test effectiveness.
|
|
229
|
+
|
|
230
|
+
**Parameters:**
|
|
231
|
+
- `dataPath` (string): Path to lineage data file (default: `.jest-lineage-data.json`)
|
|
232
|
+
- `threshold` (number): Minimum mutation score threshold 0-100 (default: 80)
|
|
233
|
+
- `timeout` (number): Timeout per mutation in milliseconds (default: 5000)
|
|
234
|
+
- `debug` (boolean): Create debug mutation files instead of running tests (default: false)
|
|
235
|
+
|
|
236
|
+
#### `generate_report`
|
|
237
|
+
Generate HTML report from existing lineage data.
|
|
238
|
+
|
|
239
|
+
**Parameters:**
|
|
240
|
+
- `dataPath` (string): Path to lineage data file (default: `.jest-lineage-data.json`)
|
|
241
|
+
- `outputPath` (string): Output HTML file path (default: `test-lineage-report.html`)
|
|
242
|
+
|
|
243
|
+
#### `query_coverage`
|
|
244
|
+
Query which tests cover specific files or lines.
|
|
245
|
+
|
|
246
|
+
**Parameters:**
|
|
247
|
+
- `file` (string, required): File path to query (e.g., "src/calculator.ts")
|
|
248
|
+
- `line` (number, optional): Line number to query
|
|
249
|
+
- `dataPath` (string): Path to lineage data file (default: `.jest-lineage-data.json`)
|
|
250
|
+
|
|
251
|
+
#### `analyze_full`
|
|
252
|
+
Run full workflow: tests, mutation testing, and generate report.
|
|
253
|
+
|
|
254
|
+
**Parameters:**
|
|
255
|
+
- `skipTests` (boolean): Skip running tests (use existing data) (default: false)
|
|
256
|
+
- `skipMutation` (boolean): Skip mutation testing (default: false)
|
|
257
|
+
- `threshold` (number): Mutation score threshold (default: 80)
|
|
258
|
+
- `outputPath` (string): Output HTML file path (default: `test-lineage-report.html`)
|
|
259
|
+
|
|
260
|
+
### Example MCP Usage with Claude
|
|
261
|
+
|
|
262
|
+
Once configured, you can ask Claude:
|
|
263
|
+
|
|
264
|
+
- "Run the tests with lineage tracking"
|
|
265
|
+
- "Run mutation testing with an 85% threshold"
|
|
266
|
+
- "Generate an HTML report from the latest test data"
|
|
267
|
+
- "Which tests cover line 42 of src/calculator.ts?"
|
|
268
|
+
- "Run a full analysis and generate the report"
|
|
269
|
+
|
|
270
|
+
Claude will use the MCP server to execute these operations in your project.
|
|
19
271
|
|
|
20
272
|
## š¦ Installation
|
|
21
273
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Jest Test Lineage Reporter CLI
|
|
5
|
+
* Main entry point for command-line interface
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const cli = require('../src/cli');
|
|
9
|
+
|
|
10
|
+
// Run CLI with error handling
|
|
11
|
+
cli.run(process.argv).catch((error) => {
|
|
12
|
+
console.error('\nā Error:', error.message);
|
|
13
|
+
|
|
14
|
+
if (process.env.JEST_LINEAGE_DEBUG === 'true') {
|
|
15
|
+
console.error('\nStack trace:');
|
|
16
|
+
console.error(error.stack);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jest-test-lineage-reporter",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"main": "src/TestCoverageReporter.js",
|
|
5
|
+
"bin": {
|
|
6
|
+
"jest-lineage": "./bin/jest-lineage.js"
|
|
7
|
+
},
|
|
5
8
|
"scripts": {
|
|
6
9
|
"test": "jest",
|
|
7
10
|
"test:watch": "jest --watch",
|
|
@@ -47,14 +50,20 @@
|
|
|
47
50
|
"npm": ">=6.0.0"
|
|
48
51
|
},
|
|
49
52
|
"files": [
|
|
50
|
-
"
|
|
51
|
-
"src/
|
|
52
|
-
"src/babel-plugin-lineage-tracker.js",
|
|
53
|
-
"src/config.js",
|
|
53
|
+
"bin/",
|
|
54
|
+
"src/",
|
|
54
55
|
"babel.config.js",
|
|
55
56
|
"README.md",
|
|
56
57
|
"LICENSE"
|
|
57
58
|
],
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
61
|
+
"chalk": "^4.1.2",
|
|
62
|
+
"cli-table3": "^0.6.3",
|
|
63
|
+
"commander": "^11.0.0",
|
|
64
|
+
"open": "^8.4.0",
|
|
65
|
+
"ora": "^5.4.1"
|
|
66
|
+
},
|
|
58
67
|
"devDependencies": {
|
|
59
68
|
"@babel/core": "^7.23.0",
|
|
60
69
|
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|