headlamp 0.1.33 → 0.1.35
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 +104 -152
- package/bin/.gitkeep +4 -0
- package/bin/darwin-arm64/headlamp +0 -0
- package/dist/cli.cjs +50 -61814
- package/dist/postinstall.cjs +181 -0
- package/package.json +24 -61
- package/dist/cli.cjs.map +0 -7
- package/dist/index.js +0 -63488
- package/dist/index.js.map +0 -7
- package/dist/jest/reporter.cjs +0 -193
- package/dist/jest/setup.cjs +0 -201
- package/scripts/build.mjs +0 -123
- package/scripts/postinstall.mjs +0 -13
- package/scripts/print-publish-log.mjs +0 -29
package/README.md
CHANGED
|
@@ -1,205 +1,157 @@
|
|
|
1
|
-
|
|
1
|
+
### Headlamp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Headlamp is a **Rust-powered test UX CLI**: smarter test selection, cleaner output, and a unified workflow across **jest**, **cargo test**, and **cargo nextest**.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Headlamp is useful when you want a consistent way to run tests across different projects and keep feedback fast as your repo grows. It can select tests based on what changed, surface failures in a readable format, and keep common defaults (like runner args and coverage settings) in a single config file so your team doesn’t have to remember a long list of flags.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### Why Headlamp
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
- **One CLI, many runners**: `--runner=jest|cargo-nextest|cargo-test`
|
|
10
|
+
- **Selection that scales**: run what changed (`--changed`) and what’s related (dependency-graph driven)
|
|
11
|
+
- **Coverage-first UX**: coverage output you can actually read
|
|
12
|
+
- **Fast**: Rust core + caching
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
### Installation
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
npm i -D headlamp
|
|
17
|
-
```
|
|
16
|
+
#### npm (recommended)
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
Requirements:
|
|
20
19
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- Selects tests by import-graph when you pass production paths
|
|
20
|
+
- Node **>= 18**
|
|
21
|
+
- A GitHub Release for your version tag (see “Releases” below)
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
Install:
|
|
26
24
|
|
|
27
25
|
```bash
|
|
28
|
-
|
|
29
|
-
npx headlamp --coverage
|
|
30
|
-
|
|
31
|
-
# Run only tests related to selected production files
|
|
32
|
-
npx headlamp src/services/user.ts src/components/UserCard.tsx
|
|
26
|
+
npm i -D headlamp
|
|
33
27
|
```
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Pass your regular Jest flags (e.g. `-t`, `--testNamePattern`, paths). Headlamp forwards them, and strips/adjusts coverage-related flags when listing tests.
|
|
38
|
-
|
|
39
|
-
### General
|
|
40
|
-
|
|
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
|
|
29
|
+
Run:
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- Effect: adds Jest `--runInBand` and runs Headlamp’s per‑project execution with stride 1 (no parallel projects)
|
|
31
|
+
```bash
|
|
32
|
+
npx headlamp --help
|
|
33
|
+
```
|
|
49
34
|
|
|
50
|
-
|
|
35
|
+
#### Cargo (from source)
|
|
51
36
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- `--changed.depth=<n>`: cap transitive import scan depth for changed-file discovery (default: 5)
|
|
37
|
+
```bash
|
|
38
|
+
cargo install --path headlamp
|
|
39
|
+
```
|
|
56
40
|
|
|
57
|
-
###
|
|
41
|
+
### Quickstart
|
|
58
42
|
|
|
59
|
-
|
|
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`
|
|
43
|
+
#### Jest
|
|
70
44
|
|
|
71
|
-
|
|
45
|
+
```bash
|
|
46
|
+
npx headlamp --runner=jest
|
|
47
|
+
```
|
|
72
48
|
|
|
73
|
-
|
|
49
|
+
Forward runner args after `--` (unknown args are forwarded):
|
|
74
50
|
|
|
75
|
-
|
|
51
|
+
```bash
|
|
52
|
+
npx headlamp --runner=jest -- --runInBand
|
|
53
|
+
```
|
|
76
54
|
|
|
77
|
-
|
|
78
|
-
- `headlamp.config.js` / `headlamp.config.mjs` / `headlamp.config.cjs`
|
|
79
|
-
- `headlamp.config.json` / `headlamp.config.yaml` / `headlamp.config.yml`
|
|
55
|
+
#### Cargo nextest / cargo test
|
|
80
56
|
|
|
81
|
-
|
|
57
|
+
```bash
|
|
58
|
+
headlamp --runner=cargo-nextest
|
|
59
|
+
headlamp --runner=cargo-test
|
|
60
|
+
```
|
|
82
61
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
62
|
+
### CLI
|
|
63
|
+
|
|
64
|
+
Current `--help` output:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
headlamp
|
|
68
|
+
|
|
69
|
+
Usage:
|
|
70
|
+
headlamp [--runner=<jest|vitest|pytest|cargo-nextest|cargo-test>] [--coverage] [--changed[=<mode>]] [args...]
|
|
71
|
+
|
|
72
|
+
Flags:
|
|
73
|
+
--runner <runner> Select runner (default: jest)
|
|
74
|
+
--coverage Enable coverage collection (runner-specific)
|
|
75
|
+
--coverage-ui=jest|both Coverage output mode
|
|
76
|
+
--coverage.abortOnFailure Exit on test failures without printing coverage
|
|
77
|
+
--watch Re-run on file changes (runner-agnostic polling watch)
|
|
78
|
+
--ci CI mode (disable interactive UI and set CI=1)
|
|
79
|
+
--verbose More Headlamp diagnostics
|
|
80
|
+
--no-cache Disable Headlamp caches (and runner caches when possible)
|
|
81
|
+
--onlyFailures Show only failing tests during live output
|
|
82
|
+
--showLogs Show full logs under failing tests
|
|
83
|
+
--sequential Serialize execution (maps to jest --runInBand)
|
|
84
|
+
--bootstrapCommand <cmd> Run once before tests (npm script name or shell cmd)
|
|
85
|
+
--changed[=all|staged|unstaged|branch|lastCommit]
|
|
86
|
+
--changed.depth=<n>
|
|
87
|
+
|
|
88
|
+
Notes:
|
|
89
|
+
Unknown args are forwarded to the runner.
|
|
90
|
+
```
|
|
86
91
|
|
|
87
|
-
###
|
|
92
|
+
### Configuration
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
Headlamp discovers config from your repo root. Supported file names:
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
- `headlamp.config.ts`
|
|
97
|
+
- `headlamp.config.js`
|
|
98
|
+
- `headlamp.config.mjs`
|
|
99
|
+
- `headlamp.config.cjs`
|
|
100
|
+
- `headlamp.config.json`
|
|
101
|
+
- `headlamp.config.json5`
|
|
102
|
+
- `headlamp.config.jsonc`
|
|
103
|
+
- `headlamp.config.yaml`
|
|
104
|
+
- `headlamp.config.yml`
|
|
105
|
+
- `.headlamprc` plus `.headlamprc.*` variants (`.json`, `.json5`, `.jsonc`, `.yaml`, `.yml`, `.js`, `.cjs`, `.mjs`, `.ts`)
|
|
100
106
|
|
|
101
|
-
|
|
107
|
+
#### Example: `headlamp.config.ts`
|
|
102
108
|
|
|
103
|
-
|
|
104
|
-
- `include`, `exclude` -> `--coverage.include`, `--coverage.exclude`
|
|
105
|
-
- `coverageDetail`, `coverageShowCode`, `coverageMaxFiles`, `coverageMaxHotspots`
|
|
109
|
+
Rules:
|
|
106
110
|
|
|
107
|
-
|
|
111
|
+
- Must have a **default export**
|
|
112
|
+
- Only **relative imports** are supported inside the config file (`./` and `../`)
|
|
108
113
|
|
|
109
114
|
```ts
|
|
110
115
|
export default {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
branch: { depth: 10 },
|
|
114
|
-
staged: { depth: 8 },
|
|
115
|
-
unstaged: { depth: 6 },
|
|
116
|
-
all: { depth: 12 },
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
```
|
|
116
|
+
// Runner defaults
|
|
117
|
+
jestArgs: ["--runInBand"],
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
// Run once before tests (npm script name or a shell command)
|
|
120
|
+
bootstrapCommand: "test:jest:bootstrap",
|
|
122
121
|
|
|
123
|
-
|
|
122
|
+
// Global toggles
|
|
123
|
+
ci: false,
|
|
124
|
+
verbose: false,
|
|
125
|
+
noCache: false,
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
|
127
|
+
// Coverage defaults
|
|
128
|
+
coverage: true,
|
|
129
|
+
coverageUi: "both",
|
|
134
130
|
coverage: {
|
|
135
131
|
abortOnFailure: true,
|
|
136
|
-
mode:
|
|
132
|
+
mode: "auto",
|
|
137
133
|
pageFit: true,
|
|
138
134
|
},
|
|
139
135
|
|
|
140
|
-
// Changed
|
|
141
|
-
changed: {
|
|
142
|
-
depth: 20,
|
|
143
|
-
branch: { depth: 10 },
|
|
144
|
-
},
|
|
136
|
+
// Changed selection defaults
|
|
137
|
+
changed: { depth: 2 },
|
|
145
138
|
};
|
|
146
139
|
```
|
|
147
140
|
|
|
148
|
-
|
|
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
|
|
141
|
+
### Contributing
|
|
161
142
|
|
|
162
|
-
|
|
143
|
+
Pull requests are welcome. For large changes, open an issue first to align on direction.
|
|
163
144
|
|
|
164
|
-
|
|
165
|
-
- With spaces: treated as a full command and executed via the system shell
|
|
166
|
-
|
|
167
|
-
Examples:
|
|
145
|
+
Local dev:
|
|
168
146
|
|
|
169
147
|
```bash
|
|
170
|
-
|
|
171
|
-
npx headlamp --bootstrapCommand "sequelize db:migrate --env test"
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## Examples
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
# Abort on failing tests without printing coverage
|
|
178
|
-
npx headlamp --coverage --coverage.abortOnFailure
|
|
179
|
-
|
|
180
|
-
# Show compact coverage limited to 50 files and 5 hotspots per file
|
|
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
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## Editor links
|
|
188
|
-
|
|
189
|
-
Headlamp prints clickable links (OSC 8) to open files at hotspots. Set `--coverage.editor` to override the default editor URL template if needed.
|
|
190
|
-
|
|
191
|
-
## API
|
|
192
|
-
|
|
193
|
-
Programmatic use:
|
|
194
|
-
|
|
195
|
-
```ts
|
|
196
|
-
import { printCompactCoverage, resolveImportWithRoot } from 'headlamp';
|
|
148
|
+
cargo test
|
|
197
149
|
```
|
|
198
150
|
|
|
199
|
-
|
|
151
|
+
### Support
|
|
200
152
|
|
|
201
|
-
|
|
153
|
+
- Bug reports and feature requests: GitHub Issues
|
|
202
154
|
|
|
203
|
-
|
|
155
|
+
### License
|
|
204
156
|
|
|
205
|
-
MIT
|
|
157
|
+
MIT — see `LICENSE`.
|
package/bin/.gitkeep
ADDED
|
Binary file
|