test-inventory 0.1.2 → 0.2.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/CHANGELOG.md +22 -0
- package/README.md +3 -10
- package/dist/extract.d.ts +30 -2
- package/dist/extract.js +349 -52
- package/dist/frameworks/bindings.d.ts +20 -12
- package/dist/frameworks/bindings.js +113 -49
- package/dist/frameworks/playwright.js +35 -12
- package/dist/frameworks/vitest.d.ts +2 -0
- package/dist/frameworks/vitest.js +34 -11
- package/dist/index.d.ts +1 -1
- package/dist/model.d.ts +2 -0
- package/dist/records.js +24 -6
- package/dist/resolve.d.ts +3 -2
- package/dist/resolve.js +227 -57
- package/dist/scan-file.js +14 -5
- package/dist/types.d.ts +18 -0
- package/dist/values.d.ts +14 -0
- package/dist/values.js +44 -3
- package/package.json +12 -9
- package/schema/v1.json +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# test-inventory
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#18](https://github.com/Huldoser/test-inventory/pull/18) [`4698945`](https://github.com/Huldoser/test-inventory/commit/46989455dda81842d0a947bafb8d1270654be250) - A custom `test` object is followed through as many files as it takes: a fixtures file may re-export it, as in `export * from './base'`, or build it with `extend` on one imported from another file. When it can't be followed, the `unresolved-test-import` message says where the chain of files ends. A test file that builds its own test object from an imported one, as in `const test = base.extend({...})`, no longer gets a `local-test-object` warning when the import is followed.
|
|
8
|
+
|
|
9
|
+
- [#18](https://github.com/Huldoser/test-inventory/pull/18) [`4698945`](https://github.com/Huldoser/test-inventory/commit/46989455dda81842d0a947bafb8d1270654be250) - Tests and describes declared in a helper function are recorded at each call of the helper from the file or a describe, in the describe around the call, as the runner registers them; before, they were listed once, where written. Titles built from the helper's parameters are worked out from each call's arguments. Helpers imported from other files are followed too: their records give the call in the scanned file as their location, and a new `declaredAt` key on test and suite records gives the file and line where the helper writes the test, `null` for code in the scanned file. Records of tests in helpers get new ids, as their describes change. The `test-in-function` warning now only marks tests in functions the scan can't place, and the call where the scan stops following helpers, after 10,000 calls in a file.
|
|
10
|
+
|
|
11
|
+
- [#18](https://github.com/Huldoser/test-inventory/pull/18) [`4698945`](https://github.com/Huldoser/test-inventory/commit/46989455dda81842d0a947bafb8d1270654be250) - Files that playwright-bdd generates from Gherkin features are read: they import Playwright's `test` from `playwright-bdd`.
|
|
12
|
+
|
|
13
|
+
- [#18](https://github.com/Huldoser/test-inventory/pull/18) [`4698945`](https://github.com/Huldoser/test-inventory/commit/46989455dda81842d0a947bafb8d1270654be250) - In Playwright, a test in a loop whose title path is the same on each pass gets a `duplicate-title` error, and the tests in its file are `notLoaded`, as Playwright refuses the file. Vitest runs duplicate titles, so nothing changes there.
|
|
14
|
+
|
|
15
|
+
- [#18](https://github.com/Huldoser/test-inventory/pull/18) [`4698945`](https://github.com/Huldoser/test-inventory/commit/46989455dda81842d0a947bafb8d1270654be250) - Path aliases come from the tsconfig nearest the importing file, as TypeScript finds it, with every file it `extends`, packages included, and `${configDir}` filled in. Without a `tsconfig.json`, the nearest `tsconfig.base.json` is used, as in an Nx workspace, and a solution-style tsconfig takes its aliases from the projects it `references`.
|
|
16
|
+
|
|
17
|
+
- [#18](https://github.com/Huldoser/test-inventory/pull/18) [`4698945`](https://github.com/Huldoser/test-inventory/commit/46989455dda81842d0a947bafb8d1270654be250) - Workspace packages are followed before an install, from the `workspaces` of `package.json` or from `pnpm-workspace.yaml`. When a package's `exports`, `types` or `main` point to build output that doesn't exist yet, as in `dist/esm/index.js`, the source next to it in `src/` is used. Patterns and links that lead out of the workspace folder are not followed.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#19](https://github.com/Huldoser/test-inventory/pull/19) [`bc7a0c3`](https://github.com/Huldoser/test-inventory/commit/bc7a0c36b364b338e1aef0c0a7622b22590a8305) - A test or hook that calls helper functions which call each other in many places no longer makes the scan hang. Each helper's states are applied once for each set of conditions it is reached under, and past 10,000 helper calls from one call, a `state-in-helper` warning says the rest are not applied.
|
|
22
|
+
|
|
23
|
+
- [#20](https://github.com/Huldoser/test-inventory/pull/20) [`7f32dd4`](https://github.com/Huldoser/test-inventory/commit/7f32dd4605e93fa0db47200b917dfafb91ac1da5) - oxc-parser is updated from 0.153.0 to 0.154.0. The scan output doesn't change.
|
|
24
|
+
|
|
3
25
|
## 0.1.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -88,20 +88,13 @@ const todo = inventory.tests.filter((test) => test.isTodo).map((test) => test.fu
|
|
|
88
88
|
|
|
89
89
|
- Config files are not read, so `grep`, projects and Vitest tag options in them do not change the output.
|
|
90
90
|
- Values imported from other files are not worked out. A tag or title that comes from an import gets a diagnostic
|
|
91
|
-
that names the module. A custom `test` object is followed
|
|
92
|
-
|
|
93
|
-
declared
|
|
91
|
+
that names the module. A custom `test` object is followed through as many files as it takes, through relative
|
|
92
|
+
paths, tsconfig path aliases, `#` imports in package.json and workspace packages; one that can't be followed gets
|
|
93
|
+
an error. Tests declared in helper functions are listed at each call, also for helpers imported from other files.
|
|
94
94
|
- A test in a loop or a `.each` table is one record, with `isInLoop` or `caseCount`; the runner creates one test per
|
|
95
95
|
iteration or case.
|
|
96
96
|
- Conditions such as `browserName === 'webkit'` are kept as source text, not evaluated.
|
|
97
97
|
|
|
98
|
-
## Performance
|
|
99
|
-
|
|
100
|
-
Files are read one at a time and the JSON is written one record at a time. Scanning the 196 Vitest files of
|
|
101
|
-
[vuejs/core](https://github.com/vuejs/core) at commit 4ab865a (3,592 tests) took 1.22 s and 187 MB of peak memory,
|
|
102
|
-
the median of nine runs of the command line pinned to two cores with `taskset -c 0,1`, on a 16-core Ryzen 7 9800X3D
|
|
103
|
-
desktop under WSL 2 with Node.js 26.9.
|
|
104
|
-
|
|
105
98
|
## Support
|
|
106
99
|
|
|
107
100
|
If test-inventory is useful to you, [star it on GitHub](https://github.com/Huldoser/test-inventory) or
|
package/dist/extract.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CallExpression } from 'oxc-parser';
|
|
2
|
-
import type { Adapter, Details, Mode, Problem, Span, StateSetting, SuiteDeclaration, TestDeclaration } from './model.ts';
|
|
2
|
+
import type { Adapter, Details, Mode, ModuleReader, ModuleSource, Problem, Span, StateSetting, SuiteDeclaration, TestDeclaration } from './model.ts';
|
|
3
3
|
import type { ParsedFile } from './parse.ts';
|
|
4
|
+
import { type SourceText } from './source.ts';
|
|
4
5
|
import type { Annotation } from './types.ts';
|
|
5
6
|
import { type Values } from './values.ts';
|
|
6
7
|
/** The file or a describe, with what is set on it. Tests inherit from every scope around them. */
|
|
@@ -13,10 +14,21 @@ export interface Scope {
|
|
|
13
14
|
details: Details;
|
|
14
15
|
suite: PendingSuite | null;
|
|
15
16
|
}
|
|
17
|
+
/** Where a test or describe registered through an imported helper is written, in the helper's module. */
|
|
18
|
+
export interface DeclaredAt {
|
|
19
|
+
relativeFilePath: string;
|
|
20
|
+
source: SourceText;
|
|
21
|
+
start: number;
|
|
22
|
+
}
|
|
16
23
|
export interface PendingSuite {
|
|
17
24
|
scope: Scope;
|
|
18
25
|
declaration: SuiteDeclaration;
|
|
19
26
|
call: CallExpression;
|
|
27
|
+
/** For a describe declared in an imported helper, the call in the scanned file that registers it; null otherwise. */
|
|
28
|
+
site: Span | null;
|
|
29
|
+
declaredAt: DeclaredAt | null;
|
|
30
|
+
/** Where the scanned file registers the describe: its own call, or the outermost helper call that declares it. */
|
|
31
|
+
order: number;
|
|
20
32
|
/** Statements of the tests and describes directly inside, left out of the describe's body hash. */
|
|
21
33
|
cuts: Span[];
|
|
22
34
|
}
|
|
@@ -24,6 +36,11 @@ export interface PendingTest {
|
|
|
24
36
|
scope: Scope;
|
|
25
37
|
declaration: TestDeclaration;
|
|
26
38
|
call: CallExpression;
|
|
39
|
+
/** For a test declared in an imported helper, the call in the scanned file that registers it; null otherwise. */
|
|
40
|
+
site: Span | null;
|
|
41
|
+
declaredAt: DeclaredAt | null;
|
|
42
|
+
/** Where the scanned file registers the test: its own call, or the outermost helper call that declares it. */
|
|
43
|
+
order: number;
|
|
27
44
|
/** States from the declaration, then from calls in the body such as `test.skip(condition)`. */
|
|
28
45
|
states: StateSetting[];
|
|
29
46
|
annotations: Annotation[];
|
|
@@ -33,6 +50,16 @@ export interface PendingTest {
|
|
|
33
50
|
comments: string[];
|
|
34
51
|
problems: Problem[];
|
|
35
52
|
}
|
|
53
|
+
/** A file the walk reads code from: the scanned file, or a module a helper function is imported from. */
|
|
54
|
+
export interface Frame {
|
|
55
|
+
parsed: ParsedFile;
|
|
56
|
+
adapter: Adapter;
|
|
57
|
+
values: Values;
|
|
58
|
+
readModule: ModuleReader | null;
|
|
59
|
+
relativeFilePath: string;
|
|
60
|
+
}
|
|
61
|
+
/** Reads a module a helper is imported from as a frame; null when it can't be parsed. */
|
|
62
|
+
export type OpenModule = (module: ModuleSource) => Frame | null;
|
|
36
63
|
export interface Extraction {
|
|
37
64
|
suites: PendingSuite[];
|
|
38
65
|
tests: PendingTest[];
|
|
@@ -40,4 +67,5 @@ export interface Extraction {
|
|
|
40
67
|
problems: Problem[];
|
|
41
68
|
usesGlobals: boolean;
|
|
42
69
|
}
|
|
43
|
-
|
|
70
|
+
/** Walks the scanned file; `openModule` reads the modules of imported helpers that the file calls. */
|
|
71
|
+
export declare function extract(main: Frame, openModule: OpenModule): Extraction;
|