test-inventory 0.11.0 → 0.11.1
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 +10 -0
- package/dist/cli.d.ts +6 -3
- package/dist/diff.js +5 -2
- package/dist/imported-values.js +12 -3
- package/dist/values.d.ts +4 -1
- package/dist/values.js +19 -9
- package/package.json +15 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# test-inventory
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#149](https://github.com/Huldoser/test-inventory/pull/149) [`3c312ac`](https://github.com/Huldoser/test-inventory/commit/3c312ac0109c424c7c4fc46efad6b0b75c4917dc) - Report a conditional skip becoming unconditional as `newlySkipped`, and the reverse as `reEnabled`.
|
|
8
|
+
|
|
9
|
+
- [#149](https://github.com/Huldoser/test-inventory/pull/149) [`3c312ac`](https://github.com/Huldoser/test-inventory/commit/3c312ac0109c424c7c4fc46efad6b0b75c4917dc) - Count rows in imported parameterized test tables when the row count is known but some row values cannot be worked out.
|
|
10
|
+
|
|
11
|
+
- [#147](https://github.com/Huldoser/test-inventory/pull/147) [`ac689fd`](https://github.com/Huldoser/test-inventory/commit/ac689fdf569751b933a6b4a79a5c58cc5e1723af) - Update oxc-parser to 0.159.0 to pick up JavaScript and TypeScript parsing fixes.
|
|
12
|
+
|
|
3
13
|
## 0.11.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
type OutputStream = Pick<Writable, keyof NodeJS.EventEmitter | 'errored' | 'write'>;
|
|
3
|
+
type InputStream = Pick<Readable, typeof Symbol.asyncIterator>;
|
|
2
4
|
export interface Io {
|
|
3
|
-
stdout:
|
|
4
|
-
stderr: Writable
|
|
5
|
+
stdout: OutputStream;
|
|
6
|
+
stderr: Pick<Writable, 'write'>;
|
|
5
7
|
cwd: string;
|
|
6
8
|
/** Read for `--related -`. */
|
|
7
|
-
stdin?:
|
|
9
|
+
stdin?: InputStream;
|
|
8
10
|
}
|
|
9
11
|
export declare const HELP = "Usage: test-inventory [glob...] [options]\n test-inventory diff old.json new.json [--format json|markdown] [--pretty] [--output file]\n\nLists the tests in the matching files as JSON, read from the source code without running them. Without globs, the\ntest files are those the runner's configs in the root and the folders below it run, or for node:test and Bun those\nnode --test and bun test run.\n\nOptions:\n --framework <name> playwright, vitest, jest, mocha, jasmine, cypress, webdriverio, node or bun\n (default: the one the project uses)\n --root <dir> project root; paths in the output are relative to it (default: current directory)\n --ignore <glob> leave out matching files; can be repeated (node_modules is always left out)\n --framework-version <x.y.z> apply the rules of this framework version instead of the one in the project\n --comments <mode> comments above tests: all, non-active or none (default: non-active)\n --expand-cases one record per case of a .each or .for table and per pass of a loop, with its title\n --state <state> keep tests in this state, such as skip or fixme; can be repeated\n --tag <tag> keep tests with this tag, such as @smoke; can be repeated\n --grep <regex> keep tests whose full name matches, ignoring case\n --only keep tests that use .only, or are inside a describe that does\n --without-reason keep non-active tests without a reason, excluding notLoaded\n --related <file> keep tests a change to this file can affect; can be repeated; - reads files, one per\n line, from standard input, as git diff --name-only writes them\n --fields <keys> write only these keys of each test, separated by commas; id is always kept\n --format <format> json, jsonl, one record per line, or commands, a command line for each config that runs\n the tests kept (default: json)\n -o, --output <file> write to a file instead of standard output\n --pretty indent the JSON\n -h, --help show this help\n -v, --version show the version\n\nExit codes: 0 when the scan finishes, even with diagnostics; 2 for invalid arguments, an output that cannot be\nwritten, or a crash. 1 is reserved for a future release.\n\nExamples:\n test-inventory \"tests/**/*.spec.ts\" --framework playwright --output inventory.json\n test-inventory \"tests/**/*.spec.ts\" --framework playwright --state skip --fields fullName,reason\n git diff --name-only main | test-inventory --related - --format commands\n";
|
|
10
12
|
/** Runs the command line with the given arguments and streams. Resolves to the exit code. */
|
|
11
13
|
export declare function run(argv: string[], io: Io): Promise<number>;
|
|
14
|
+
export {};
|
package/dist/diff.js
CHANGED
|
@@ -98,10 +98,13 @@ function kindsOf(before, after, fields) {
|
|
|
98
98
|
kinds.push('dependenciesChanged');
|
|
99
99
|
const disabled = (test) => ['skip', 'fixme', 'todo'].includes(test.state);
|
|
100
100
|
const runnable = (test) => ['active', 'expectedToFail'].includes(test.state);
|
|
101
|
-
|
|
101
|
+
const disabledUnderDifferentConditions = before.isConditional !== after.isConditional && disabled(before) && disabled(after);
|
|
102
|
+
if ((runnable(before) && disabled(after)) || (disabledUnderDifferentConditions && !after.isConditional)) {
|
|
102
103
|
kinds.push('newlySkipped');
|
|
103
|
-
|
|
104
|
+
}
|
|
105
|
+
if ((disabled(before) && runnable(after)) || (disabledUnderDifferentConditions && after.isConditional)) {
|
|
104
106
|
kinds.push('reEnabled');
|
|
107
|
+
}
|
|
105
108
|
if (fields.includes('state'))
|
|
106
109
|
kinds.push('stateChanged');
|
|
107
110
|
if (fields.includes('tags'))
|
package/dist/imported-values.js
CHANGED
|
@@ -69,9 +69,18 @@ export class ExportedValues {
|
|
|
69
69
|
return opened.values.resolveName(name, [program]);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
const resolve = (value) => {
|
|
73
|
+
const scopes = [program];
|
|
74
|
+
const result = typeof value === 'string' ? opened.values.resolveName(value, scopes) : opened.values.resolve(value, scopes);
|
|
75
|
+
if (result.ok)
|
|
76
|
+
return result;
|
|
77
|
+
// A failure may refer to an unresolved part of this expression, so only keep the length of the export itself.
|
|
78
|
+
const arrayLength = typeof value === 'string' ? opened.values.lengthOfName(value, scopes) : opened.values.lengthOf(value, scopes);
|
|
79
|
+
return arrayLength === null ? UNRESOLVED : { ...UNRESOLVED, arrayLength };
|
|
80
|
+
};
|
|
72
81
|
const own = ownExport(program, name);
|
|
73
82
|
if (own?.kind === 'default')
|
|
74
|
-
return
|
|
83
|
+
return resolve(own.value);
|
|
75
84
|
if (own?.kind === 'function')
|
|
76
85
|
return UNRESOLVED;
|
|
77
86
|
if (own?.kind === 'specifier' && own.source !== null) {
|
|
@@ -79,11 +88,11 @@ export class ExportedValues {
|
|
|
79
88
|
return 'reason' in from ? UNRESOLVED : (this.exported(from, own.local) ?? UNRESOLVED);
|
|
80
89
|
}
|
|
81
90
|
if (own) {
|
|
82
|
-
return
|
|
91
|
+
return resolve(own.kind === 'specifier' ? own.local : name);
|
|
83
92
|
}
|
|
84
93
|
const commonJs = commonJsExport(program, name);
|
|
85
94
|
if (commonJs)
|
|
86
|
-
return
|
|
95
|
+
return resolve(commonJs);
|
|
87
96
|
// What `require()` gives for a module that exports its names one by one: an object of them.
|
|
88
97
|
const names = name === 'default' ? commonJsNames(program) : [];
|
|
89
98
|
if (names.length > 0) {
|
package/dist/values.d.ts
CHANGED
|
@@ -3,13 +3,14 @@ import { type FunctionNode } from './ast.ts';
|
|
|
3
3
|
export type Value = string | number | boolean | null | undefined | Value[] | {
|
|
4
4
|
[key: string]: Value;
|
|
5
5
|
};
|
|
6
|
-
/** A value
|
|
6
|
+
/** A resolved value or a failed lookup. `arrayLength` can record the size of an imported array with unknown items. */
|
|
7
7
|
export type Resolved = {
|
|
8
8
|
ok: true;
|
|
9
9
|
value: Value;
|
|
10
10
|
} | {
|
|
11
11
|
ok: false;
|
|
12
12
|
importedFrom: string | null;
|
|
13
|
+
arrayLength?: number;
|
|
13
14
|
};
|
|
14
15
|
/** What another module exports under a name, `default` included, for an import of the file. */
|
|
15
16
|
export type ImportReader = (source: string, name: string) => Resolved;
|
|
@@ -106,6 +107,8 @@ export declare class Values {
|
|
|
106
107
|
* null otherwise. `seen` stops at a constant defined through itself.
|
|
107
108
|
*/
|
|
108
109
|
lengthOf(node: Expression, scopes: readonly Node[], seen?: Set<string>): number | null;
|
|
110
|
+
/** How many items a named array holds, including a project import whose values are unknown. */
|
|
111
|
+
lengthOfName(name: string, scopes: readonly Node[], seen?: Set<string>): number | null;
|
|
109
112
|
/** How many keys an object written out has, held in a constant the module doesn't change; null otherwise. */
|
|
110
113
|
private keyCount;
|
|
111
114
|
/** What a name refers to where it is used; `scopes` lists the scope nodes around the use, outermost first. */
|
package/dist/values.js
CHANGED
|
@@ -495,7 +495,7 @@ export class Values {
|
|
|
495
495
|
}
|
|
496
496
|
imported(source, name) {
|
|
497
497
|
const resolved = name !== null && this.imports ? this.imports(source, name) : UNRESOLVED;
|
|
498
|
-
return resolved.ok ? resolved : {
|
|
498
|
+
return resolved.ok ? resolved : { ...resolved, importedFrom: source };
|
|
499
499
|
}
|
|
500
500
|
/**
|
|
501
501
|
* How many items a list has when not all its values are known, as `[NaN, Infinity]`: a list written out, its spreads
|
|
@@ -503,17 +503,15 @@ export class Values {
|
|
|
503
503
|
* null otherwise. `seen` stops at a constant defined through itself.
|
|
504
504
|
*/
|
|
505
505
|
lengthOf(node, scopes, seen = new Set()) {
|
|
506
|
+
const expression = unwrap(node);
|
|
507
|
+
if (expression.type === 'Identifier')
|
|
508
|
+
return this.lengthOfName(expression.name, scopes, seen);
|
|
506
509
|
const resolved = this.resolve(node, scopes);
|
|
507
510
|
if (resolved.ok)
|
|
508
511
|
return Array.isArray(resolved.value) ? resolved.value.length : null;
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
if (binding?.kind !== 'const' || seen.has(expression.name))
|
|
513
|
-
return null;
|
|
514
|
-
if (this.changedAtLoad(binding.scopes[0]).has(expression.name))
|
|
515
|
-
return null;
|
|
516
|
-
return this.lengthOf(binding.init, binding.scopes, new Set([...seen, expression.name]));
|
|
512
|
+
if (expression.type === 'MemberExpression') {
|
|
513
|
+
const member = this.namespaceMember(expression, scopes);
|
|
514
|
+
return member?.ok === false ? (member.arrayLength ?? null) : null;
|
|
517
515
|
}
|
|
518
516
|
if (expression.type === 'CallExpression' && isObjectListing(expression)) {
|
|
519
517
|
const target = expression.arguments[0];
|
|
@@ -530,6 +528,18 @@ export class Values {
|
|
|
530
528
|
}
|
|
531
529
|
return length;
|
|
532
530
|
}
|
|
531
|
+
/** How many items a named array holds, including a project import whose values are unknown. */
|
|
532
|
+
lengthOfName(name, scopes, seen = new Set()) {
|
|
533
|
+
const resolved = this.resolveName(name, scopes);
|
|
534
|
+
if (resolved.ok)
|
|
535
|
+
return Array.isArray(resolved.value) ? resolved.value.length : null;
|
|
536
|
+
const binding = this.lookup(name, scopes)?.binding;
|
|
537
|
+
if (binding?.kind === 'import')
|
|
538
|
+
return resolved.arrayLength ?? null;
|
|
539
|
+
if (binding?.kind !== 'const' || seen.has(name) || this.changedAtLoad(binding.scopes[0]).has(name))
|
|
540
|
+
return null;
|
|
541
|
+
return this.lengthOf(binding.init, binding.scopes, new Set([...seen, name]));
|
|
542
|
+
}
|
|
533
543
|
/** How many keys an object written out has, held in a constant the module doesn't change; null otherwise. */
|
|
534
544
|
keyCount(node, scopes, seen) {
|
|
535
545
|
const expression = unwrap(node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-inventory",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Lists every Playwright, Vitest, Jest, Mocha, Jasmine, Cypress, WebdriverIO, node:test and Bun test from the source code, without running it: its state and why, tags, an id that survives a move, a hash of everything it runs, and the tests a change can affect.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"testing",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"changeset": "changeset"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"oxc-parser": "0.
|
|
90
|
+
"oxc-parser": "0.159.0",
|
|
91
91
|
"picomatch": "^4.0.7",
|
|
92
92
|
"tinyglobby": "^0.2.17"
|
|
93
93
|
},
|
|
@@ -97,19 +97,27 @@
|
|
|
97
97
|
"@changesets/cli": "^3.0.3",
|
|
98
98
|
"@types/node": "~22.12.0",
|
|
99
99
|
"@types/picomatch": "^4.0.3",
|
|
100
|
-
"@vitest/coverage-v8": "5.1.
|
|
100
|
+
"@vitest/coverage-v8": "5.1.1",
|
|
101
101
|
"ajv": "^8.20.0",
|
|
102
|
-
"eslint": "~10.
|
|
103
|
-
"prettier": "3.
|
|
102
|
+
"eslint": "~10.15.0",
|
|
103
|
+
"prettier": "3.10.1",
|
|
104
104
|
"publint": "^0.3.25",
|
|
105
105
|
"ts-json-schema-generator": "2.9.0",
|
|
106
106
|
"typedoc": "^0.28.20",
|
|
107
107
|
"typedoc-plugin-markdown": "^4.14.1",
|
|
108
108
|
"typedoc-vitepress-theme": "^1.1.4",
|
|
109
109
|
"typescript": "~6.0.3",
|
|
110
|
-
"typescript-eslint": "~8.
|
|
110
|
+
"typescript-eslint": "~8.73.0",
|
|
111
111
|
"vitepress": "2.0.0-alpha.21",
|
|
112
112
|
"vitepress-plugin-llms": "^1.14.0",
|
|
113
|
-
"vitest": "5.1.
|
|
113
|
+
"vitest": "5.1.1"
|
|
114
|
+
},
|
|
115
|
+
"overrides": {
|
|
116
|
+
"ts-json-schema-generator": {
|
|
117
|
+
"glob": "^14.0.6"
|
|
118
|
+
},
|
|
119
|
+
"vitepress-plugin-llms": {
|
|
120
|
+
"minimatch": "^11.0.9"
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
}
|