test-inventory 0.12.2 → 0.12.3
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/CHANGELOG.md +6 -0
- package/README.md +74 -50
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# test-inventory
|
|
2
2
|
|
|
3
|
+
## 0.12.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#162](https://github.com/Huldoser/test-inventory/pull/162) [`3badf47`](https://github.com/Huldoser/test-inventory/commit/3badf47122baebe2de93941c3e28e3ac28d0fa88) - Update the package description and getting-started guides for scanning suites and comparing revisions.
|
|
8
|
+
|
|
3
9
|
## 0.12.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,47 +1,59 @@
|
|
|
1
1
|
# <picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Huldoser/test-inventory/main/docs/public/logo-dark.svg"><img src="https://raw.githubusercontent.com/Huldoser/test-inventory/main/docs/public/logo-light.svg" alt="test-inventory" height="48"></picture>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Find skipped tests, catch pull requests that weaken your test suite, and get the runner commands for tests a git diff can affect, without running the suite.
|
|
4
4
|
|
|
5
|
-
test-inventory
|
|
6
|
-
JSON. Each test record includes its title, location, suite, tags, annotations and state. Conditional states keep the
|
|
7
|
-
condition as source text; they do not establish what happened in a particular run.
|
|
5
|
+
test-inventory parses Playwright, Vitest, Jest, Mocha, Jasmine, Cypress, WebdriverIO, node:test and Bun test files and configs from source. It needs no browsers, no build and no runner setup. CI checks the output against all 9 runners and scans 24 public repositories (69,127 tests across 7,095 files) on every pull request with zero parse errors: see [real projects](https://huldoser.github.io/test-inventory/guide/real-projects) and [runner comparisons](https://huldoser.github.io/test-inventory/guide/runners).
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
runner configs and project imports without executing them. It needs no browsers, build or additional runner setup.
|
|
11
|
-
Check diagnostics before treating a scan as complete; [known limits](https://huldoser.github.io/test-inventory/guide/limits)
|
|
12
|
-
describes what static analysis can miss.
|
|
7
|
+
Documentation: [huldoser.github.io/test-inventory](https://huldoser.github.io/test-inventory/) · [Framework guides](https://huldoser.github.io/test-inventory/frameworks/)
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
code, dependencies, state and tags, as JSON or Markdown. See [Compare inventories](https://huldoser.github.io/test-inventory/guide/diff).
|
|
9
|
+
## Three ways to use it
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
| Tool | Best for |
|
|
12
|
+
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
13
|
+
| **CLI and library** (`test-inventory`) | Audit skipped tests, get runner commands for a git diff, compare saved scans, or read test metadata as JSON. |
|
|
14
|
+
| **GitHub Action** ([test-inventory-action](https://github.com/Huldoser/test-inventory-action)) | Comment on pull requests when tests won't run, get turned off, are removed, or lose their assertions. |
|
|
15
|
+
| **MCP server** ([test-inventory-mcp](https://github.com/Huldoser/test-inventory-mcp)) | Let Claude Code, Cursor, VS Code and other AI clients query tests and get run commands without running them. |
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
Each covers its runner's scan commands, examples, syntax and limitations.
|
|
17
|
+
## Try it in 5 seconds
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
Run directly in any JavaScript or TypeScript project with Node.js 22.12 or newer. No install needed, and the scanner detects the runner and reads its config automatically.
|
|
20
|
+
|
|
21
|
+
List skipped and fixme tests with their conditions and reasons:
|
|
23
22
|
|
|
24
23
|
```sh
|
|
25
|
-
|
|
24
|
+
npx test-inventory --state skip --state fixme --fields fullName,state,condition,reason --pretty
|
|
26
25
|
```
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
Print the exact runner command for tests affected by your current branch:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
git diff --name-only origin/main... | npx test-inventory --related - --format commands
|
|
31
|
+
```
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
```text
|
|
34
|
+
npx playwright test tests/orders/limit-orders.spec.ts tests/orders/market-orders.spec.ts tests/orders/order-lifecycle.spec.ts tests/portfolio.spec.ts --config playwright.config.ts --project chromium webkit
|
|
35
|
+
```
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
Compare two saved scans to track additions, removals, renames, moves and newly skipped tests:
|
|
35
38
|
|
|
36
39
|
```sh
|
|
37
|
-
npx test-inventory
|
|
40
|
+
npx test-inventory diff base.json head.json --format markdown
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
In a project with several runners, pass `--framework <name>`. Pass quoted globs to select specific files instead of reading runner configs, or see your [framework guide](https://huldoser.github.io/test-inventory/frameworks/).
|
|
44
|
+
|
|
45
|
+
## Pull request comments (GitHub Action)
|
|
46
|
+
|
|
47
|
+
[Test changes by test-inventory](https://github.com/marketplace/actions/test-changes-by-test-inventory) compares a pull request's base and head from source and comments when tests need a look before merging. It needs no project install, works on pull requests from forks and never fails a check.
|
|
48
|
+
|
|
49
|
+
<picture>
|
|
50
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Huldoser/test-inventory-action/main/docs/comment-dark.png">
|
|
51
|
+
<img alt="Pull request comment showing 5 tests that need a look: 2 won't run, 1 is turned off, 1 was removed and 1 has no assertions left, each linked to its line" src="https://raw.githubusercontent.com/Huldoser/test-inventory-action/main/docs/comment-light.png" width="820">
|
|
52
|
+
</picture>
|
|
53
|
+
|
|
54
|
+
Setup uses two short workflows in [test-inventory-action](https://github.com/Huldoser/test-inventory-action#usage).
|
|
55
|
+
|
|
56
|
+
## What the JSON looks like
|
|
45
57
|
|
|
46
58
|
For this spec from a trading app's UI tests, `tests/alerts.spec.ts`:
|
|
47
59
|
|
|
@@ -67,7 +79,15 @@ test.describe('price alerts', () => {
|
|
|
67
79
|
});
|
|
68
80
|
```
|
|
69
81
|
|
|
70
|
-
|
|
82
|
+
Running a scan:
|
|
83
|
+
|
|
84
|
+
<!-- scan: trading-web -->
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
npx test-inventory "tests/**/*.spec.ts" --framework playwright --output inventory.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
produces a deterministic record for each test, including:
|
|
71
91
|
|
|
72
92
|
<!-- output: trading-web -->
|
|
73
93
|
|
|
@@ -87,42 +107,46 @@ the first test's record includes:
|
|
|
87
107
|
}
|
|
88
108
|
```
|
|
89
109
|
|
|
90
|
-
|
|
91
|
-
scan could not read and values it could not work out. Filters such as `--state skip`, `--tag @smoke` and
|
|
92
|
-
`--grep "limit order"` keep only some tests, `--fields fullName,reason` keeps only some keys, `--format jsonl`
|
|
93
|
-
writes one record per line, and `--format commands` prints the command lines that run the tests kept.
|
|
110
|
+
Each scan also includes `summary` counts, `suites`, `configs`, `files` and `diagnostics`. Ids stay stable when tests move lines, and `bodyHash` / `dependencyHash` support [inventory diffs](https://huldoser.github.io/test-inventory/guide/diff) and `--related` filtering. Use `--state`, `--tag`, `--grep`, `--fields` and `--format jsonl` or `--format commands` to narrow the output; see the [CLI reference](https://huldoser.github.io/test-inventory/guide/cli).
|
|
94
111
|
|
|
95
|
-
##
|
|
112
|
+
## Install and library
|
|
113
|
+
|
|
114
|
+
For CI, scripts or programmatic use, install as a dev dependency:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
npm install --save-dev test-inventory
|
|
118
|
+
```
|
|
96
119
|
|
|
97
120
|
```ts
|
|
98
|
-
import { scan } from 'test-inventory';
|
|
121
|
+
import { filterInventory, runCommands, scan } from 'test-inventory';
|
|
99
122
|
|
|
100
123
|
const inventory = await scan({ patterns: ['tests/**/*.test.ts'], framework: 'vitest' });
|
|
101
124
|
const todo = inventory.tests.filter((test) => test.isTodo).map((test) => test.fullName);
|
|
125
|
+
const commands = runCommands(filterInventory(inventory, { related: ['src/orders/pricing.ts'] }));
|
|
102
126
|
```
|
|
103
127
|
|
|
104
|
-
`scanSource()` scans
|
|
105
|
-
|
|
128
|
+
`scanSource()` scans one file in memory without reading from disk, and `diffInventories()` compares two saved scans. JSON Schemas are exported as `test-inventory/schema/v1.json` and `test-inventory/schema/diff-v1.json`.
|
|
129
|
+
|
|
130
|
+
**Requirements:** Node.js 22.12 or newer on Linux, macOS or Windows. Supports Playwright 1.31+, Vitest 1.0+, Jest 27.0+, Mocha 10.0+, Jasmine 3.0+, Cypress 10.0+, WebdriverIO 7.0+, node:test 22.0+ and Bun 1.2.23+.
|
|
131
|
+
|
|
132
|
+
## AI agents (MCP)
|
|
133
|
+
|
|
134
|
+
[test-inventory-mcp](https://github.com/Huldoser/test-inventory-mcp) gives coding agents structured tools to summarize tests, inspect skip reasons and get run commands for changed files.
|
|
106
135
|
|
|
107
|
-
|
|
136
|
+
In Claude Code, from your project folder:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@latest
|
|
140
|
+
```
|
|
108
141
|
|
|
109
|
-
[test-inventory-mcp](https://github.com/Huldoser/test-inventory-mcp)
|
|
110
|
-
in Claude Code, Cursor, VS Code and other MCP clients ask it which tests a project has without running them. The
|
|
111
|
-
[AI agents](https://huldoser.github.io/test-inventory/guide/agents) page has the setup and the other ways in.
|
|
142
|
+
Setup for Cursor, VS Code and other clients is in [test-inventory-mcp](https://github.com/Huldoser/test-inventory-mcp#setup) and the [AI agents guide](https://huldoser.github.io/test-inventory/guide/agents).
|
|
112
143
|
|
|
113
144
|
## Limits
|
|
114
145
|
|
|
115
|
-
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- Values from installed packages are not worked out; values from the project's own files are. A tag or title that
|
|
120
|
-
comes from a package gets a diagnostic that names the module. A custom `test` object is followed through as many files as it takes, through relative
|
|
121
|
-
paths, config and tsconfig path aliases, `#` imports in package.json and workspace packages; one that can't be followed gets
|
|
122
|
-
an error. Tests declared in helper functions are listed at each call, also for helpers imported from other files.
|
|
123
|
-
- A test in a loop or a `.each` table is one record, with `isInLoop` or `caseCount`; the runner creates one test per
|
|
124
|
-
iteration or case. `--expand-cases` lists each case whose values the scan can work out as its own record.
|
|
125
|
-
- Conditions such as `browserName === 'webkit'` are kept as source text, not evaluated.
|
|
146
|
+
- **Static declarations, not execution results:** the scanner reads code and configs without running them, so runtime conditions like `browserName === 'webkit'` are kept as source text and runtime-computed configs can leave values unknown.
|
|
147
|
+
- **Project imports only:** local files, tsconfig/config aliases, `#` imports and workspace packages are followed; installed packages in `node_modules` are not.
|
|
148
|
+
- **Declarations by default:** loops and `.each` tables are one record with `caseCount` unless you pass `--expand-cases`.
|
|
149
|
+
- **Check `diagnostics`:** errors indicate parse failures, unresolved imports or unreadable config settings where tests may be missing. See [known limits](https://huldoser.github.io/test-inventory/guide/limits).
|
|
126
150
|
|
|
127
151
|
## Support
|
|
128
152
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-inventory",
|
|
3
|
-
"version": "0.12.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.12.3",
|
|
4
|
+
"description": "Scan JS/TS test suites without running them: find skipped tests, diff revisions, and get commands for changed files.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"testing",
|
|
7
7
|
"playwright",
|