headlamp 0.1.17 → 0.1.19
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 +134 -106
- package/dist/cli.cjs +54951 -924
- package/dist/cli.cjs.map +4 -4
- package/dist/index.js +55120 -1087
- package/dist/index.js.map +4 -4
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,159 +1,187 @@
|
|
|
1
1
|
# Headlamp CLI
|
|
2
2
|
|
|
3
|
-
Coverage-first, runner-agnostic test UX for Jest
|
|
3
|
+
Coverage-first, runner-agnostic test UX for Jest. Delegates execution to your runner, focuses on better selection and coverage insights.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
Only in /Users/david/src/headlamp/src/lib: \_exec.ts
|
|
9
|
-
Files /Users/david/src/gigworx-node/scripts/cli/coverage-print.ts and /Users/david/src/headlamp/src/lib/coverage-print.ts differ
|
|
10
|
-
Files /Users/david/src/gigworx-node/scripts/cli/discovery.ts and /Users/david/src/headlamp/src/lib/discovery.ts differ
|
|
11
|
-
Only in /Users/david/src/headlamp/src/lib: env-utils.ts
|
|
12
|
-
Only in /Users/david/src/headlamp/src/lib: fast-related.ts
|
|
13
|
-
Files /Users/david/src/gigworx-node/scripts/cli/graph-distance.ts and /Users/david/src/headlamp/src/lib/graph-distance.ts differ
|
|
14
|
-
Files /Users/david/src/gigworx-node/scripts/cli/index.ts and /Users/david/src/headlamp/src/lib/index.ts differ
|
|
15
|
-
Files /Users/david/src/gigworx-node/scripts/cli/program.ts and /Users/david/src/headlamp/src/lib/program.ts differ
|
|
7
|
+
Use via npx (recommended):
|
|
16
8
|
|
|
17
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npx headlamp --help
|
|
11
|
+
```
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
Or install locally:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm i -D headlamp
|
|
17
|
+
```
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
- Delegates to your local Jest install
|
|
23
22
|
- Renders improved coverage tables and hotspots
|
|
24
23
|
- Selects tests by import-graph when you pass production paths
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
Quick examples:
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
```bash
|
|
28
|
+
# Run tests with coverage
|
|
29
|
+
npx headlamp --coverage
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
# Run only tests related to selected production files
|
|
32
|
+
npx headlamp src/services/user.ts src/components/UserCard.tsx
|
|
33
|
+
```
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
und hotspots
|
|
35
|
+
## CLI flags
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
- `--coverage.maxFiles`, `--coverage.maxHotspots`: limit rows to fit your terminal
|
|
37
|
-
- `--coverage.pageFit=true|false`: adapt output to terminal rows
|
|
37
|
+
Pass your regular Jest flags (e.g. `-t`, `--testNamePattern`, paths). Headlamp forwards them, and strips/adjusts coverage-related flags when listing tests.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
### General
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
- `--bootstrapCommand <cmd>`: run once before tests (npm script name or full shell command)
|
|
42
|
+
- `--onlyFailures[=true|false]`: show only failing tests during live output; always shows final summary
|
|
43
|
+
- `--showLogs[=true|false]`: include full console output under failing tests/files
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
### Concurrency
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```
|
|
47
|
+
- `--sequential[=true|false]`: serialize execution
|
|
48
|
+
- Effect: adds Jest `--runInBand` and runs Headlamp’s per‑project execution with stride 1 (no parallel projects)
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
### Selection
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
- `paths...`: any file/dir paths; production paths trigger related test discovery by import graph
|
|
53
|
+
- `-t <pattern>` / `--testNamePattern <pattern>`: filter by test name
|
|
54
|
+
- `--changed[=all|staged|unstaged|branch|lastCommit]`: select tests related to changed files
|
|
55
|
+
- `--changed.depth=<n>`: cap transitive import scan depth for changed-file discovery (default: 5)
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
### Coverage
|
|
56
58
|
|
|
57
|
-
- `--
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
- `--coverage`: enable coverage collection and merged reporting
|
|
60
|
+
- `--coverage.ui=jest|both` (alias: `--coverage-ui`): output mode for Istanbul text reports (default: `both`)
|
|
61
|
+
- `--coverage.abortOnFailure`: exit immediately with test code and skip coverage print on failures
|
|
62
|
+
- Display/detail options:
|
|
63
|
+
- `--coverage.mode=compact|full|auto` (default: `auto`)
|
|
64
|
+
- `--coverage.detail=<n>|all|auto` (default: `auto`)
|
|
65
|
+
- `--coverage.showCode=true|false` (default: `true` on TTY)
|
|
66
|
+
- `--coverage.maxFiles=<n>`
|
|
67
|
+
- `--coverage.maxHotspots=<n>`
|
|
68
|
+
- `--coverage.pageFit=true|false` (default: `true` on TTY)
|
|
69
|
+
- Globbing filters: `--coverage.include=a,b,c`, `--coverage.exclude=a,b,c`
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
## Configuration
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
# Show only failures during the run, but still print the final summary
|
|
66
|
-
npx headlamp --onlyFailures
|
|
73
|
+
Project-level file at repo root. CLI always overrides config. No env vars or hidden presets.
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
npx headlamp --changed --onlyFailures
|
|
70
|
-
```
|
|
75
|
+
### Supported filenames
|
|
71
76
|
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- Supported forms: `--showLogs`, `--showLogs=true`, `--showLogs=false`.
|
|
76
|
-
- Works alongside `--onlyFailures`, coverage flags, and selection flags.
|
|
77
|
+
- `headlamp.config.ts`
|
|
78
|
+
- `headlamp.config.js` / `headlamp.config.mjs` / `headlamp.config.cjs`
|
|
79
|
+
- `headlamp.config.json` / `headlamp.config.yaml` / `headlamp.config.yml`
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
### Base defaults (always applied)
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
- `bootstrapCommand: string`
|
|
84
|
+
- `jestArgs: string[]`
|
|
85
|
+
- `sequential?: boolean` – serialize tests across Jest and Headlamp
|
|
83
86
|
|
|
84
|
-
|
|
85
|
-
npx headlamp --onlyFailures --showLogs
|
|
86
|
-
```
|
|
87
|
+
### Coverage-context defaults (applied only when coverage is active)
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- `--changed[=mode]` selects tests by files changed in your working tree or branch.
|
|
91
|
-
- Modes:
|
|
92
|
-
- `all` (default when `--changed` is passed without a value): includes staged + unstaged + untracked files.
|
|
93
|
-
- `staged`: only staged changes.
|
|
94
|
-
- `unstaged`: only unstaged + untracked files.
|
|
95
|
-
- `branch`: union of
|
|
96
|
-
- files changed on the current branch relative to the default branch (via merge-base), and
|
|
97
|
-
- your current uncommitted changes (staged, unstaged tracked, and untracked files).
|
|
98
|
-
- Default branch is resolved via `origin/HEAD` when available, falling back to `origin/main` or `origin/master`.
|
|
99
|
-
- Effects:
|
|
100
|
-
- Uses changed production files as seeds to discover related tests by import-graph.
|
|
101
|
-
- Coverage tables prioritize and annotate files related to selection/changed files.
|
|
102
|
-
- Additional flags:
|
|
103
|
-
- `--changed.depth=<n>`: cap the transitive import scan depth when refining related tests from changed production files. Default: 5. Increase to include more indirectly-related tests (slower), decrease for speed.
|
|
89
|
+
Prefer the nested `coverage` section:
|
|
104
90
|
|
|
105
|
-
|
|
91
|
+
```ts
|
|
92
|
+
export default {
|
|
93
|
+
coverage: {
|
|
94
|
+
abortOnFailure: true, // -> --coverage.abortOnFailure
|
|
95
|
+
mode: 'auto', // -> --coverage.mode=auto
|
|
96
|
+
pageFit: true, // -> --coverage.pageFit=true
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
```
|
|
106
100
|
|
|
107
|
-
|
|
108
|
-
# Staged changes only
|
|
109
|
-
npx headlamp --changed=staged
|
|
101
|
+
Additional recognized fields when coverage is active:
|
|
110
102
|
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
- `editorCmd` -> `--coverage.editor`
|
|
104
|
+
- `include`, `exclude` -> `--coverage.include`, `--coverage.exclude`
|
|
105
|
+
- `coverageDetail`, `coverageShowCode`, `coverageMaxFiles`, `coverageMaxHotspots`
|
|
113
106
|
|
|
114
|
-
|
|
115
|
-
npx headlamp --changed=branch
|
|
107
|
+
### Changed-context defaults (applied only when changed selection is active)
|
|
116
108
|
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
```ts
|
|
110
|
+
export default {
|
|
111
|
+
changed: {
|
|
112
|
+
depth: 20, // default for all modes -> --changed.depth=20
|
|
113
|
+
branch: { depth: 10 },
|
|
114
|
+
staged: { depth: 8 },
|
|
115
|
+
unstaged: { depth: 6 },
|
|
116
|
+
all: { depth: 12 },
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
You may also set a top‑level default mode (e.g., `changed: 'branch'`); CLI still wins.
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
# Scan imports up to 10 levels deep when resolving related tests for changed files
|
|
125
|
-
npx headlamp --changed=all --changed.depth=10
|
|
123
|
+
### Full example
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
```ts
|
|
126
|
+
// headlamp.config.ts
|
|
127
|
+
export default {
|
|
128
|
+
// Base
|
|
129
|
+
bootstrapCommand: 'test:jest:bootstrap',
|
|
130
|
+
sequential: true, // serialize tests (maps to Jest --runInBand and single-project stride)
|
|
131
|
+
jestArgs: ['--runInBand'], // optional: redundant when sequential is true
|
|
132
|
+
|
|
133
|
+
// Coverage-context
|
|
134
|
+
coverage: {
|
|
135
|
+
abortOnFailure: true,
|
|
136
|
+
mode: 'auto',
|
|
137
|
+
pageFit: true,
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
// Changed-context
|
|
141
|
+
changed: {
|
|
142
|
+
depth: 20,
|
|
143
|
+
branch: { depth: 10 },
|
|
144
|
+
},
|
|
145
|
+
};
|
|
129
146
|
```
|
|
130
147
|
|
|
131
|
-
##
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
## Scripts
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"scripts": {
|
|
153
|
+
"test": "headlamp --sequential",
|
|
154
|
+
"test:coverage": "headlamp --coverage --sequential",
|
|
155
|
+
"test:dev": "npm run test -- --changed=branch --coverage --onlyFailures"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Bootstrap command
|
|
161
|
+
|
|
162
|
+
Use `--bootstrapCommand` to run setup work before tests (e.g., database migrations/seeding). If omitted, no bootstrap runs.
|
|
163
|
+
|
|
164
|
+
- Single token: treated as an npm script name and run as `npm run -s <name>`
|
|
165
|
+
- With spaces: treated as a full command and executed via the system shell
|
|
148
166
|
|
|
149
167
|
Examples:
|
|
150
168
|
|
|
169
|
+
```bash
|
|
170
|
+
npx headlamp --bootstrapCommand test:jest:bootstrap
|
|
171
|
+
npx headlamp --bootstrapCommand "sequelize db:migrate --env test"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Examples
|
|
175
|
+
|
|
151
176
|
```bash
|
|
152
177
|
# Abort on failing tests without printing coverage
|
|
153
178
|
npx headlamp --coverage --coverage.abortOnFailure
|
|
154
179
|
|
|
155
180
|
# Show compact coverage limited to 50 files and 5 hotspots per file
|
|
156
181
|
npx headlamp --coverage --coverage.mode=compact --coverage.maxFiles=50 --coverage.maxHotspots=5
|
|
182
|
+
|
|
183
|
+
# Sequential run to avoid DB deadlocks
|
|
184
|
+
npx headlamp --sequential
|
|
157
185
|
```
|
|
158
186
|
|
|
159
187
|
## Editor links
|
|
@@ -162,7 +190,7 @@ Headlamp prints clickable links (OSC 8) to open files at hotspots. Set `--covera
|
|
|
162
190
|
|
|
163
191
|
## API
|
|
164
192
|
|
|
165
|
-
|
|
193
|
+
Programmatic use:
|
|
166
194
|
|
|
167
195
|
```ts
|
|
168
196
|
import { printCompactCoverage, resolveImportWithRoot } from 'headlamp';
|