test-inventory 0.12.0 → 0.12.2
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 +145 -0
- package/README.md +3 -1
- package/dist/ast.d.ts +7 -2
- package/dist/ast.js +43 -3
- package/dist/case-titles.d.ts +5 -11
- package/dist/case-titles.js +69 -55
- package/dist/config-runs.d.ts +19 -2
- package/dist/config-runs.js +380 -91
- package/dist/config.d.ts +0 -5
- package/dist/config.js +0 -7
- package/dist/dependency-hash.js +1 -32
- package/dist/diagnostics.js +17 -2
- package/dist/diff.d.ts +2 -45
- package/dist/extract.d.ts +13 -3
- package/dist/extract.js +837 -89
- package/dist/frameworks/bun.js +47 -24
- package/dist/frameworks/common.d.ts +4 -2
- package/dist/frameworks/common.js +10 -11
- package/dist/frameworks/jasmine-registration.d.ts +47 -0
- package/dist/frameworks/jasmine-registration.js +632 -0
- package/dist/frameworks/jasmine.d.ts +7 -1
- package/dist/frameworks/jasmine.js +65 -70
- package/dist/frameworks/jest.d.ts +2 -2
- package/dist/frameworks/jest.js +126 -51
- package/dist/frameworks/test-functions.js +3 -1
- package/dist/frameworks/vitest.d.ts +2 -3
- package/dist/frameworks/vitest.js +80 -16
- package/dist/generator-steps.d.ts +56 -0
- package/dist/generator-steps.js +254 -0
- package/dist/model.d.ts +37 -5
- package/dist/mutation-arrays.d.ts +25 -0
- package/dist/mutation-arrays.js +229 -0
- package/dist/mutation-calls.d.ts +33 -0
- package/dist/mutation-calls.js +774 -0
- package/dist/mutation-order.d.ts +19 -0
- package/dist/mutation-order.js +55 -0
- package/dist/mutation-references.d.ts +109 -0
- package/dist/mutation-references.js +462 -0
- package/dist/mutation-returns.d.ts +13 -0
- package/dist/mutation-returns.js +71 -0
- package/dist/node-scripts.d.ts +6 -1
- package/dist/node-scripts.js +79 -11
- package/dist/options.d.ts +2 -0
- package/dist/options.js +6 -1
- package/dist/records.d.ts +5 -3
- package/dist/records.js +81 -28
- package/dist/scan-file.d.ts +18 -4
- package/dist/scan-file.js +44 -5
- package/dist/scan-source.js +2 -1
- package/dist/scan.js +30 -13
- package/dist/types.d.ts +45 -1
- package/dist/values.d.ts +72 -18
- package/dist/values.js +651 -172
- package/dist/vitest-concurrency.d.ts +16 -0
- package/dist/vitest-concurrency.js +55 -0
- package/package.json +6 -6
- package/schema/v1.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,150 @@
|
|
|
1
1
|
# test-inventory
|
|
2
2
|
|
|
3
|
+
## 0.12.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#159](https://github.com/Huldoser/test-inventory/pull/159) [`dbae2c9`](https://github.com/Huldoser/test-inventory/commit/dbae2c91bb77d900e711cceda2f0709ace1c8d60) - Match Bun's table titles for indexed and nested fields, missing fields followed by punctuation, and row values that contain placeholder text.
|
|
8
|
+
Mark a file or suite as not loaded when a Bun table title reads a property through an explicitly null or undefined field.
|
|
9
|
+
Handle array arguments in named placeholders and match Bun when the initial placeholder key begins with a digit.
|
|
10
|
+
|
|
11
|
+
- [#159](https://github.com/Huldoser/test-inventory/pull/159) [`dbae2c9`](https://github.com/Huldoser/test-inventory/commit/dbae2c91bb77d900e711cceda2f0709ace1c8d60) - Apply Jasmine's empty-suite rules by version and allow unused callback arguments on focused and skipped suites.
|
|
12
|
+
Recognize suites whose spec declarations cannot run, and account for code evaluated in hook arguments.
|
|
13
|
+
Mark specs registered after a nested Jasmine declaration error as not loaded, with their earlier siblings and recovery paths preserved.
|
|
14
|
+
Keep Jasmine files runnable when they catch their own registration errors.
|
|
15
|
+
Assign recovery specs to the suite Jasmine leaves open after it rejects an empty suite.
|
|
16
|
+
Omit Jasmine recovery specs when the guarded registrations and local helpers complete without throwing.
|
|
17
|
+
Collect specs declared while evaluating Jasmine runner arguments in call order, stopping at a synchronous exception.
|
|
18
|
+
Use supplied helper arguments when deciding which parameter defaults register specs.
|
|
19
|
+
Honor synchronous errors from invalid spreads and destructuring in Jasmine declaration arguments.
|
|
20
|
+
Read string elements and boxed properties in helper parameters so registration defaults and generated titles match the runner.
|
|
21
|
+
Apply argument ordering and parameter binding to direct Jasmine helper calls and immediately invoked functions.
|
|
22
|
+
Attach Jasmine declarations and hooks to the suite left open by their arguments.
|
|
23
|
+
Preserve the current Jasmine suite across the synchronous part of an async registration helper.
|
|
24
|
+
Collect successive statements after a Jasmine helper suspends in microtask order, with their captured parameters.
|
|
25
|
+
Omit unreachable Jasmine registrations after an async return, a rejected await or a promise that remains pending.
|
|
26
|
+
Exclude unreachable Jasmine recovery specs after awaiting a primitive literal.
|
|
27
|
+
Honor returns through Jasmine async helpers’ try, catch and finally blocks when collecting subsequent specs.
|
|
28
|
+
Distinguish a rejected async helper from an exception thrown while evaluating its arguments in a Jasmine spec file.
|
|
29
|
+
Account for registrations and exceptions from calls inside arguments to local Jasmine helpers when checking a catch.
|
|
30
|
+
Check generator parameter defaults and destructuring at the call, including specs registered while binding a default.
|
|
31
|
+
Stop registration at a parameter read before initialization while preserving reads deferred inside a closure.
|
|
32
|
+
Use the arguments supplied to ordinary Jasmine helpers when checking whether a default or the function body reaches the caller's catch.
|
|
33
|
+
Mark suites with a generator callback as refused by Jasmine and keep recovery with the handler that catches the refusal.
|
|
34
|
+
Check the children registered through local helpers before collecting specs after a Jasmine suite.
|
|
35
|
+
Report rejected Jasmine hooks, exclude them from hook counts and follow registration into the caller's catch.
|
|
36
|
+
Read Jasmine hook callbacks and timeouts supplied through array or string spreads.
|
|
37
|
+
Track registration and recovery when Jasmine rejects a spec callback or timeout, including pending and spread declarations.
|
|
38
|
+
Collect Jasmine suites and their specs when an array supplies the title and callback, and follow recovery after a rejected callback.
|
|
39
|
+
Read Jasmine test and suite names returned by synchronous local functions and track errors while evaluating those calls.
|
|
40
|
+
Match the names Jasmine reports for primitive spec and suite descriptions, including zero and false.
|
|
41
|
+
Read Jasmine titles built from helper results and follow evaluated operands during registration.
|
|
42
|
+
Choose the correct title branch when a Jasmine registration returns a suite, spec or hook result.
|
|
43
|
+
Format Jasmine array titles containing known primitive values or nested arrays.
|
|
44
|
+
Preserve holes and evaluated helper or spread elements in Jasmine array descriptions.
|
|
45
|
+
Follow standard string, array and object methods returned from Jasmine registration helpers.
|
|
46
|
+
Format ordinary object descriptions in Jasmine, including data objects inside arrays and object spreads.
|
|
47
|
+
Stop Jasmine argument evaluation when it spreads a noniterable helper result, async generator object, or Jasmine spec or suite result.
|
|
48
|
+
Follow synchronous generator calls consumed by spreads in Jasmine registration arguments.
|
|
49
|
+
Track the first and repeated consumption of saved synchronous iterators in Jasmine registration arguments.
|
|
50
|
+
Follow explicit synchronous generator steps during Jasmine registration, including yielded and returned values, exhaustion and cleanup.
|
|
51
|
+
Use values sent by `next(value)` when a Jasmine generator resumes and preserve the order of registrations around suspended call arguments.
|
|
52
|
+
Follow yields inside arithmetic, template strings and branching expressions so Jasmine collects the chosen titles in order.
|
|
53
|
+
Apply the same evaluation to fresh generator spreads and retain earlier delegated yields when the generator recovers from an exception.
|
|
54
|
+
Forward explicit iterator methods through Jasmine generator delegation and use the inner generator's completion value in titles.
|
|
55
|
+
Use caught values in Jasmine generator titles and preserve their lexical bindings across yields.
|
|
56
|
+
|
|
57
|
+
- [#159](https://github.com/Huldoser/test-inventory/pull/159) [`dbae2c9`](https://github.com/Huldoser/test-inventory/commit/dbae2c91bb77d900e711cceda2f0709ace1c8d60) - Count the single fallback test when Jest cannot format a table title, and report the file as not loaded when it happens in a parameterized suite.
|
|
58
|
+
Ignore the supplied callback and timeout when Jest rejects an empty or malformed table.
|
|
59
|
+
Count the rows that Jest registers when a valid table has a missing or non-callable test callback.
|
|
60
|
+
Use the titles Jest registers for functions and undefined values, and mark files with rejected test or suite titles as not loaded.
|
|
61
|
+
Account for declarations called without arguments, including the tests registered by parameterized tables.
|
|
62
|
+
Read local function and class name properties, including static name fields used in Jest table titles.
|
|
63
|
+
Read titles from methods on local object literals and expand table rows when a final explicit property supplies the title.
|
|
64
|
+
Mark files as not loaded when Bun rejects an anonymous computed method used as a title with a separate callback.
|
|
65
|
+
Resolve titles from local class methods, prototype methods and static fields in initialization order.
|
|
66
|
+
Use the Bun version to determine whether a static field gives an anonymous function its test title.
|
|
67
|
+
Expand rows titled by inherited methods and use the derived class when the title is its prototype constructor.
|
|
68
|
+
Flag titles and table data changed through aliases or shared children of shallow copies, so the inventory does not report stale values.
|
|
69
|
+
Track writes and deletes through optional chains and aliases selected by conditional, logical and sequence expressions.
|
|
70
|
+
Keep a title readable when a write changes a separate declaration with the same name.
|
|
71
|
+
Follow aliases assigned after declaration, including destructuring, and keep earlier captures tied to their original objects.
|
|
72
|
+
Flag possible changes to titles through the arguments of local helpers called during test collection.
|
|
73
|
+
Follow possible returned objects even when the same helper is called inside its own argument or another branch returns no value.
|
|
74
|
+
Follow local constant aliases of functions when collecting tests or tracking writes through helper arguments.
|
|
75
|
+
Track possible writes through callbacks passed to local helpers, keeping each callback paired with its own arguments.
|
|
76
|
+
Follow callback parameters through local aliases and selection expressions, including defaults when a supplied callback could be missing.
|
|
77
|
+
Track writes by local functions invoked through `call`, `apply`, or `Reflect.apply`, including writes to the receiver.
|
|
78
|
+
Follow literal and named array spreads when `Reflect.apply` invokes a helper during collection. Track indexed assignments that replace its target, receiver, or arguments before the call, including when a spread copies the array. Follow collection-time array edits that move or replace these values.
|
|
79
|
+
Track receiver and argument writes made when a bound local function runs during collection.
|
|
80
|
+
Follow writes by functions returned from local helpers when those functions run during collection, including local methods selected from objects and arrays. Account for writes made by local getters and setters.
|
|
81
|
+
Use the array element selected when an argument is evaluated, including arguments captured by a bound function and values returned by repeated helper calls.
|
|
82
|
+
Follow a collection-time helper that replaces or deletes a slot in an array supplied by its caller.
|
|
83
|
+
Track array methods invoked on helper parameters during collection, including the caller’s references to inserted elements.
|
|
84
|
+
Follow array edits through parameters and receivers captured by returned local functions.
|
|
85
|
+
Keep untouched test titles exact when a returned setter is the only possible function, and retain both possibilities when its factory is uncertain.
|
|
86
|
+
Follow array edits through nested helper calls in execution order, including forwarded callbacks.
|
|
87
|
+
Resolve reads inside a helper against writes already made during the same invocation.
|
|
88
|
+
Follow methods installed on a local object by an earlier helper call.
|
|
89
|
+
Follow callbacks selected from a module-level object or array passed to a local helper, including when separate calls supply different containers.
|
|
90
|
+
Track array edits made by a callback installed and invoked during the same collection helper.
|
|
91
|
+
Re-read a forwarded callback after an intervening write, including writes made inside another local helper.
|
|
92
|
+
Follow the replacement when a callback changes its own entry before a repeated helper call.
|
|
93
|
+
|
|
94
|
+
- [#159](https://github.com/Huldoser/test-inventory/pull/159) [`dbae2c9`](https://github.com/Huldoser/test-inventory/commit/dbae2c91bb77d900e711cceda2f0709ace1c8d60) - Respect a root Mocha script's file selection during discovery. A script that names its specs no longer picks up unrelated files directly under `test/` through Mocha's default spec.
|
|
95
|
+
|
|
96
|
+
Combine Mocha's configured specs, extensions, ignores and preloads with the command line, honor `--no-recursive`, and prefer existing literal spec paths to glob expansion. During discovery, apply simple package-script file filters from Jest, Vitest and Playwright, including Playwright commands in packages without a config.
|
|
97
|
+
|
|
98
|
+
Follow literal working-directory changes before runner commands and include Playwright project prerequisites and teardown when filtering files. Match Mocha's ignore paths, config aliases, comma-separated settings, preload resolution and extensionless spec lookup.
|
|
99
|
+
|
|
100
|
+
Match Mocha's glob character classes and extension-list spacing. Omit Playwright setup and teardown selected only by empty or hook-only specs.
|
|
101
|
+
|
|
102
|
+
Honor shell `true` and `false` in conditional directory changes. Apply Playwright project title filters before selecting setup, recognize imports that only export data, and match Mocha ignore character classes and extended patterns.
|
|
103
|
+
|
|
104
|
+
Collect tests registered by a helper called directly on a CommonJS import, such as `require('./checks').validateOrder()`.
|
|
105
|
+
|
|
106
|
+
Follow Playwright tests registered when local modules load. Honor Playwright's file filtering when tests originate in a helper with a different extension, including matching enclosing describes.
|
|
107
|
+
|
|
108
|
+
Honor TypeScript import removal when collecting Playwright registrations, including imports used only in type annotations and imports retained for JSX.
|
|
109
|
+
|
|
110
|
+
Assign a shared Playwright module's top-level tests to the first spec that loads it in each command, including when deciding whether a setup project runs.
|
|
111
|
+
|
|
112
|
+
Follow immediately invoked functions during Playwright collection and skip module initialization in branches ruled out by a known condition.
|
|
113
|
+
|
|
114
|
+
Keep shared Playwright registrations in the spec that reaches the import when a loop is empty or a statement exits early.
|
|
115
|
+
|
|
116
|
+
Discover extensionless Mocha preloads under linked project roots and preserve Vitest file filters that contain Windows short directory names.
|
|
117
|
+
|
|
118
|
+
- [#159](https://github.com/Huldoser/test-inventory/pull/159) [`dbae2c9`](https://github.com/Huldoser/test-inventory/commit/dbae2c91bb77d900e711cceda2f0709ace1c8d60) - Match Vitest's version-specific handling of inherited only, skip and todo options, including their precedence over configured tags in Vitest 4.1. Report the suite that supplied a test's todo state when nested suites have different modes.
|
|
119
|
+
|
|
120
|
+
Report forbidden focus from a configured tag and check it before a test body or hook can skip.
|
|
121
|
+
|
|
122
|
+
Follow Vitest's nested focus selection from 4.0.17 when reporting `isOnly` on siblings.
|
|
123
|
+
|
|
124
|
+
Honor nested `fails: false` options and version-specific tag precedence when reporting expected failures.
|
|
125
|
+
Preserve a test's failure expectation when a focus tag makes it run.
|
|
126
|
+
|
|
127
|
+
Report Vitest concurrency from nested suite options, modifiers, tags and the root scheduling default through Vitest 4 and the selected project's default from Vitest 5, including the change to `concurrent: false` in 4.1.6 and the removal of the `sequential` option in Vitest 5.
|
|
128
|
+
|
|
129
|
+
Keep the table declaration and report a warning when Vitest projects sharing a file generate different case titles.
|
|
130
|
+
|
|
131
|
+
Report when a runtime title-length setting prevents the scan from determining a Vitest case name.
|
|
132
|
+
|
|
133
|
+
Collect Vitest suites with a function as the title and a separate callback, and report the native title for unnamed functions and classes.
|
|
134
|
+
Follow local function aliases used as titles, including class names overridden by static fields in Vitest and declared names in Bun.
|
|
135
|
+
|
|
136
|
+
Match Bun callback-only declarations, unnamed titles, invalid descriptors, and skipped or todo declarations with omitted callbacks.
|
|
137
|
+
|
|
138
|
+
## 0.12.1
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- [#157](https://github.com/Huldoser/test-inventory/pull/157) [`dafab8b`](https://github.com/Huldoser/test-inventory/commit/dafab8b7108fa9ee58b107e016be13a0837db5af) - Discover Playwright specs when a package script runs `playwright test` without a config file. Default file matching and ignore rules apply from the package folder.
|
|
143
|
+
|
|
144
|
+
- [#157](https://github.com/Huldoser/test-inventory/pull/157) [`dafab8b`](https://github.com/Huldoser/test-inventory/commit/dafab8b7108fa9ee58b107e016be13a0837db5af) - Update oxc-parser to 0.160.0 for TypeScript parsing fixes, including comparisons after `as` and `satisfies`.
|
|
145
|
+
|
|
146
|
+
- [#157](https://github.com/Huldoser/test-inventory/pull/157) [`dafab8b`](https://github.com/Huldoser/test-inventory/commit/dafab8b7108fa9ee58b107e016be13a0837db5af) - Recognize a re-exported Vitest test called with a title, options, a body and an extra argument.
|
|
147
|
+
|
|
3
148
|
## 0.12.0
|
|
4
149
|
|
|
5
150
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -38,7 +38,9 @@ npx test-inventory "tests/**/*.spec.ts" --framework playwright --output inventor
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
Without the glob, the test files are those the project's Playwright, Vitest, Jest, Mocha, Jasmine, Cypress or
|
|
41
|
-
WebdriverIO configs run, or for node:test and Bun the files `node --test` and `bun test` run.
|
|
41
|
+
WebdriverIO configs run, or for node:test and Bun the files `node --test` and `bun test` run. A package script running
|
|
42
|
+
`playwright test` can also discover specs without a config. During discovery, simple file arguments in Jest, Vitest
|
|
43
|
+
and Playwright package scripts narrow the files collected by those commands. Without `--framework`, the
|
|
42
44
|
scan takes the runner the project uses, and asks for `--framework` when it uses several.
|
|
43
45
|
|
|
44
46
|
For this spec from a trading app's UI tests, `tests/alerts.spec.ts`:
|
package/dist/ast.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type FunctionNode = Function | ArrowFunctionExpression;
|
|
|
3
3
|
export declare function childNodes(node: Node): Node[];
|
|
4
4
|
/** Strips TypeScript-only wrappers such as `test!`, `test as any` and `<any>test`. */
|
|
5
5
|
export declare function unwrap(node: Expression): Expression;
|
|
6
|
+
/** The expression that supplies a reference when an optional chain reaches its operand. */
|
|
7
|
+
export declare function unwrapChain(node: Expression): Expression;
|
|
6
8
|
export declare function isFunctionNode(node: Node | null | undefined): node is FunctionNode;
|
|
7
9
|
/** A value a function returns, with the nodes inside the function around its `return`, outermost first. */
|
|
8
10
|
export interface ReturnValue {
|
|
@@ -12,9 +14,10 @@ export interface ReturnValue {
|
|
|
12
14
|
/**
|
|
13
15
|
* The values a function returns; null when it may return no value, as with `return;` or no `return` at all, and for
|
|
14
16
|
* an async function or a generator, which returns a promise or an iterator whatever its `return` says. With `awaited`,
|
|
15
|
-
* an async function's values are those its promise resolves to. A
|
|
17
|
+
* an async function's values are those its promise resolves to. A bare return can be ignored when looking for
|
|
18
|
+
* objects that might be returned. A nested function's returns belong to the nested function.
|
|
16
19
|
*/
|
|
17
|
-
export declare function returnValues(fn: FunctionNode, awaited?: boolean): ReturnValue[] | null;
|
|
20
|
+
export declare function returnValues(fn: FunctionNode, awaited?: boolean, bare?: 'unknown' | 'ignore'): ReturnValue[] | null;
|
|
18
21
|
export declare function isStringLiteral(node: Node): node is StringLiteral;
|
|
19
22
|
/** `import.meta.vitest`, which in-source Vitest tests read their functions from. */
|
|
20
23
|
export declare function isImportMetaVitest(expression: Expression): boolean;
|
|
@@ -25,3 +28,5 @@ export declare function propertyKey(property: {
|
|
|
25
28
|
}): string | null;
|
|
26
29
|
/** The property name of `a.b` or `a['b']`; null for other computed or private properties. */
|
|
27
30
|
export declare function propertyName(member: MemberExpression): string | null;
|
|
31
|
+
/** Whether an identifier refers to a binding, rather than naming a property, a label or a member. */
|
|
32
|
+
export declare function isReference(key: string | null, parent: Node | null): boolean;
|
package/dist/ast.js
CHANGED
|
@@ -29,15 +29,21 @@ export function unwrap(node) {
|
|
|
29
29
|
}
|
|
30
30
|
return current;
|
|
31
31
|
}
|
|
32
|
+
/** The expression that supplies a reference when an optional chain reaches its operand. */
|
|
33
|
+
export function unwrapChain(node) {
|
|
34
|
+
const value = unwrap(node);
|
|
35
|
+
return value.type === 'ChainExpression' ? unwrap(value.expression) : value;
|
|
36
|
+
}
|
|
32
37
|
export function isFunctionNode(node) {
|
|
33
38
|
return node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression';
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
41
|
* The values a function returns; null when it may return no value, as with `return;` or no `return` at all, and for
|
|
37
42
|
* an async function or a generator, which returns a promise or an iterator whatever its `return` says. With `awaited`,
|
|
38
|
-
* an async function's values are those its promise resolves to. A
|
|
43
|
+
* an async function's values are those its promise resolves to. A bare return can be ignored when looking for
|
|
44
|
+
* objects that might be returned. A nested function's returns belong to the nested function.
|
|
39
45
|
*/
|
|
40
|
-
export function returnValues(fn, awaited = false) {
|
|
46
|
+
export function returnValues(fn, awaited = false, bare = 'unknown') {
|
|
41
47
|
if ((fn.async && !awaited) || fn.generator)
|
|
42
48
|
return null;
|
|
43
49
|
// Only declarations of overloads have no body.
|
|
@@ -49,7 +55,10 @@ export function returnValues(fn, awaited = false) {
|
|
|
49
55
|
const around = [];
|
|
50
56
|
const visit = (node) => {
|
|
51
57
|
if (node.type === 'ReturnStatement') {
|
|
52
|
-
|
|
58
|
+
if (node.argument)
|
|
59
|
+
values.push({ expression: node.argument, around: [...around] });
|
|
60
|
+
else if (bare === 'unknown')
|
|
61
|
+
values.push(null);
|
|
53
62
|
return;
|
|
54
63
|
}
|
|
55
64
|
if (node.type === 'FunctionDeclaration' || isFunctionNode(node))
|
|
@@ -84,3 +93,34 @@ export function propertyName(member) {
|
|
|
84
93
|
}
|
|
85
94
|
return isStringLiteral(member.property) ? member.property.value : null;
|
|
86
95
|
}
|
|
96
|
+
/** Whether an identifier refers to a binding, rather than naming a property, a label or a member. */
|
|
97
|
+
export function isReference(key, parent) {
|
|
98
|
+
switch (parent?.type) {
|
|
99
|
+
case 'MemberExpression':
|
|
100
|
+
return key === 'object' || parent.computed;
|
|
101
|
+
case 'Property':
|
|
102
|
+
case 'MethodDefinition':
|
|
103
|
+
case 'PropertyDefinition':
|
|
104
|
+
case 'AccessorProperty':
|
|
105
|
+
case 'TSPropertySignature':
|
|
106
|
+
case 'TSMethodSignature':
|
|
107
|
+
return key !== 'key' || parent.computed;
|
|
108
|
+
case 'LabeledStatement':
|
|
109
|
+
case 'BreakStatement':
|
|
110
|
+
case 'ContinueStatement':
|
|
111
|
+
return false;
|
|
112
|
+
case 'TSEnumMember':
|
|
113
|
+
case 'TSModuleDeclaration':
|
|
114
|
+
case 'TSTypeParameter':
|
|
115
|
+
case 'TSImportEqualsDeclaration':
|
|
116
|
+
return key !== 'id' && key !== 'name';
|
|
117
|
+
case 'TSQualifiedName':
|
|
118
|
+
return key === 'left';
|
|
119
|
+
case 'ExportSpecifier':
|
|
120
|
+
return key === 'local';
|
|
121
|
+
case 'MetaProperty':
|
|
122
|
+
return false;
|
|
123
|
+
default:
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
package/dist/case-titles.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ import type { Value } from './values.ts';
|
|
|
9
9
|
*
|
|
10
10
|
* `version` is Vitest's `[major, minor]`, null for the newest rules. `truncate` is the length Vitest shortens a value to,
|
|
11
11
|
* 40 unless the config sets `chaiConfig.truncateThreshold` (3 and 4) or `taskTitleValueFormatTruncate` (5); 0 keeps
|
|
12
|
-
* values whole.
|
|
12
|
+
* values whole. With an unknown length (null), only substitutions independent of the setting can be rendered.
|
|
13
13
|
*/
|
|
14
|
-
export declare function vitestCaseTitle(template: string, items: readonly Value[], index: number, version: readonly [number, number] | null, truncate?: number): string | null;
|
|
14
|
+
export declare function vitestCaseTitle(template: string, items: readonly Value[], index: number, version: readonly [number, number] | null, truncate?: number | null): string | null;
|
|
15
15
|
/**
|
|
16
16
|
* The title Jest gives one row of a `.each` table of arrays, or of single values, read from `jest-each` 29.0, 29.7,
|
|
17
17
|
* 30.0 and 30.5: `%#` and from 30.0 `%$` for the row's index, then one placeholder per item, in order. `%p` shows the
|
|
@@ -25,12 +25,6 @@ export declare function jestRowTitle(template: string, row: readonly Value[], in
|
|
|
25
25
|
* stays as written. Null when Jest fails the table, as when a path goes through `null` before 30.0.
|
|
26
26
|
*/
|
|
27
27
|
export declare function jestKeysTitle(template: string, item: Record<string, Value>, index: number, version: readonly [number, number] | null, keepsEscapes: boolean): string | null;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* a string, `%d` and `%f` a number, `%i` an integer, `%j` and `%o` any value as JSON; a value of another type leaves
|
|
32
|
-
* the placeholder as written, but is used up. `%#` is the index, `%%` a `%`, and `%` before any other character is
|
|
33
|
-
* dropped. Once the values are used up, the rest stays as written. Null where Bun pretty-prints: `%p`, and `$key`
|
|
34
|
-
* of an object, `null` or `undefined`.
|
|
35
|
-
*/
|
|
36
|
-
export declare function bunCaseTitle(template: string, args: readonly Value[], index: number, version: readonly [number, number] | null): string | null;
|
|
28
|
+
export declare const BUN_INVALID_TITLE: unique symbol;
|
|
29
|
+
/** Bun reads both kinds of placeholders from the template. It never interprets text inserted from a row. */
|
|
30
|
+
export declare function bunCaseTitle(template: string, args: readonly Value[], index: number, version: readonly [number, number] | null): string | null | typeof BUN_INVALID_TITLE;
|
package/dist/case-titles.js
CHANGED
|
@@ -9,7 +9,7 @@ import { format } from 'node:util';
|
|
|
9
9
|
*
|
|
10
10
|
* `version` is Vitest's `[major, minor]`, null for the newest rules. `truncate` is the length Vitest shortens a value to,
|
|
11
11
|
* 40 unless the config sets `chaiConfig.truncateThreshold` (3 and 4) or `taskTitleValueFormatTruncate` (5); 0 keeps
|
|
12
|
-
* values whole.
|
|
12
|
+
* values whole. With an unknown length (null), only substitutions independent of the setting can be rendered.
|
|
13
13
|
*/
|
|
14
14
|
export function vitestCaseTitle(template, items, index, version, truncate = 40) {
|
|
15
15
|
const rules = version === null || version[0] >= 5 ? 5 : version[0];
|
|
@@ -167,6 +167,8 @@ function formatValue(placeholder, value, rules, truncate) {
|
|
|
167
167
|
}
|
|
168
168
|
/** A string cut to `length` with an ellipsis, without splitting a surrogate pair; 0 keeps it whole. */
|
|
169
169
|
function shorten(text, length) {
|
|
170
|
+
if (length === null)
|
|
171
|
+
return text === '…' ? text : null;
|
|
170
172
|
if (length === 0 || text.length <= length)
|
|
171
173
|
return text;
|
|
172
174
|
let end = length - 1;
|
|
@@ -184,6 +186,8 @@ function prettyFormat(value, truncate) {
|
|
|
184
186
|
if (typeof value !== 'string')
|
|
185
187
|
return Object.is(value, -0) ? '-0' : String(value);
|
|
186
188
|
const quoted = `'${value}'`;
|
|
189
|
+
if (truncate === null)
|
|
190
|
+
return value === '…' ? quoted : null;
|
|
187
191
|
if (truncate === 0 || quoted.length <= truncate)
|
|
188
192
|
return quoted;
|
|
189
193
|
let end = truncate - 1;
|
|
@@ -206,6 +210,8 @@ function loupe(value, truncate) {
|
|
|
206
210
|
return null;
|
|
207
211
|
if (typeof value === 'string') {
|
|
208
212
|
const escaped = value.replace(LOUPE_ESCAPED, (char) => LOUPE_ESCAPES[char] ?? `\\u${`0000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
|
|
213
|
+
if (truncate === null)
|
|
214
|
+
return escaped.length <= 1 ? `'${escaped}'` : null;
|
|
209
215
|
return `'${loupeTruncate(escaped, truncate - 2)}'`;
|
|
210
216
|
}
|
|
211
217
|
if (typeof value !== 'number')
|
|
@@ -214,7 +220,10 @@ function loupe(value, truncate) {
|
|
|
214
220
|
return String(value);
|
|
215
221
|
if (value === 0)
|
|
216
222
|
return Object.is(value, -0) ? '-0' : '+0';
|
|
217
|
-
|
|
223
|
+
const text = String(value);
|
|
224
|
+
if (truncate === null)
|
|
225
|
+
return text.length <= 1 ? text : null;
|
|
226
|
+
return loupeTruncate(text, truncate);
|
|
218
227
|
}
|
|
219
228
|
function loupeTruncate(text, length) {
|
|
220
229
|
if (length < 1 && text.length > 1)
|
|
@@ -327,76 +336,81 @@ function prettyFormatMin(value, depth = 0) {
|
|
|
327
336
|
const keys = Object.keys(value).sort();
|
|
328
337
|
return `{${keys.map((key) => `${prettyFormatMin(key)}: ${prettyFormatMin(value[key], depth + 1)}`).join(', ')}}`;
|
|
329
338
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
339
|
+
const BUN_KEY_PATH = /\d\w*|[a-zA-Z_$][\w$]*(?:\.[\w$]+)*/y;
|
|
340
|
+
export const BUN_INVALID_TITLE = Symbol('invalid Bun table title');
|
|
341
|
+
/** Bun accepts decimal indices after a dot. A digit cannot start a top-level key. */
|
|
342
|
+
function bunProperty(row, path) {
|
|
343
|
+
if (!path || /^\d/.test(path))
|
|
344
|
+
return undefined;
|
|
345
|
+
let value = row;
|
|
346
|
+
for (const key of path.split('.')) {
|
|
347
|
+
if (value === null || value === undefined)
|
|
348
|
+
return BUN_INVALID_TITLE;
|
|
349
|
+
const object = Object(value);
|
|
350
|
+
if (!Object.hasOwn(object, key))
|
|
351
|
+
return key in object ? NOT_PLAIN : undefined;
|
|
352
|
+
value = object[key];
|
|
353
|
+
}
|
|
354
|
+
return value;
|
|
355
|
+
}
|
|
356
|
+
/** Bun reads both kinds of placeholders from the template. It never interprets text inserted from a row. */
|
|
338
357
|
export function bunCaseTitle(template, args, index, version) {
|
|
339
|
-
let text = template;
|
|
340
358
|
const [first] = args;
|
|
341
|
-
|
|
342
|
-
const quotes = version !== null && (version[0] < 1 || (version[0] === 1 && version[1] < 3));
|
|
343
|
-
const shown = { all: true };
|
|
344
|
-
text = text.replace(/\$([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)/g, (written, path) => {
|
|
345
|
-
let value = first;
|
|
346
|
-
for (const key of path.split('.')) {
|
|
347
|
-
value = value !== null && typeof value === 'object' && !Array.isArray(value) ? value[key] : undefined;
|
|
348
|
-
}
|
|
349
|
-
if (value === undefined && !hasPath(first, path))
|
|
350
|
-
return written;
|
|
351
|
-
if (typeof value === 'string')
|
|
352
|
-
return quotes ? JSON.stringify(value) : value;
|
|
353
|
-
if (typeof value === 'number')
|
|
354
|
-
return Object.is(value, -0) ? '-0' : String(value);
|
|
355
|
-
if (typeof value === 'boolean')
|
|
356
|
-
return String(value);
|
|
357
|
-
shown.all = false;
|
|
358
|
-
return written;
|
|
359
|
-
});
|
|
360
|
-
if (!shown.all)
|
|
361
|
-
return null;
|
|
362
|
-
}
|
|
359
|
+
const quotes = version !== null && (version[0] < 1 || (version[0] === 1 && version[1] < 3));
|
|
363
360
|
let out = '';
|
|
364
361
|
let used = 0;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
362
|
+
let known = true;
|
|
363
|
+
for (let at = 0; at < template.length; at++) {
|
|
364
|
+
const char = template[at];
|
|
365
|
+
if (char === '$' && first !== null && typeof first === 'object') {
|
|
366
|
+
BUN_KEY_PATH.lastIndex = at + 1;
|
|
367
|
+
const path = BUN_KEY_PATH.exec(template)?.[0] ?? '';
|
|
368
|
+
at += path.length;
|
|
369
|
+
// Bun can split a UTF-8 sequence when it advances past an unknown key.
|
|
370
|
+
if (template.charCodeAt(at + 1) > 127)
|
|
371
|
+
return null;
|
|
372
|
+
const value = bunProperty(first, path);
|
|
373
|
+
if (value === BUN_INVALID_TITLE)
|
|
374
|
+
return value;
|
|
375
|
+
if (value === undefined || value === null) {
|
|
376
|
+
out += '$' + path;
|
|
377
|
+
at++;
|
|
378
|
+
}
|
|
379
|
+
else if (typeof value === 'string')
|
|
380
|
+
out += quotes ? JSON.stringify(value) : value.toWellFormed();
|
|
381
|
+
else if (typeof value === 'number')
|
|
382
|
+
out += Object.is(value, -0) ? '-0' : String(value);
|
|
383
|
+
else if (typeof value === 'boolean')
|
|
384
|
+
out += String(value);
|
|
385
|
+
else
|
|
386
|
+
known = false;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (char !== '%' || at === template.length - 1 || used >= args.length) {
|
|
368
390
|
out += char;
|
|
369
391
|
continue;
|
|
370
392
|
}
|
|
371
|
-
|
|
372
|
-
return out + text.slice(at);
|
|
373
|
-
const placeholder = text[++at];
|
|
393
|
+
const placeholder = template[at + 1];
|
|
374
394
|
if (placeholder === '#')
|
|
375
395
|
out += String(index);
|
|
376
396
|
else if (placeholder === '%')
|
|
377
397
|
out += '%';
|
|
378
|
-
else if (placeholder === 'p')
|
|
379
|
-
|
|
398
|
+
else if (placeholder === 'p') {
|
|
399
|
+
used++;
|
|
400
|
+
known = false;
|
|
401
|
+
}
|
|
380
402
|
else if ('sdfijo'.includes(placeholder)) {
|
|
381
403
|
const formatted = bunValue(placeholder, args[used++]);
|
|
382
404
|
if (formatted === null)
|
|
383
|
-
|
|
384
|
-
|
|
405
|
+
known = false;
|
|
406
|
+
else
|
|
407
|
+
out += formatted;
|
|
385
408
|
}
|
|
386
409
|
else
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return out;
|
|
390
|
-
}
|
|
391
|
-
/** Whether an object has a value at a dotted path, `undefined` included. */
|
|
392
|
-
function hasPath(item, path) {
|
|
393
|
-
let value = item;
|
|
394
|
-
for (const key of path.split('.')) {
|
|
395
|
-
if (value === null || typeof value !== 'object' || Array.isArray(value) || !(key in value))
|
|
396
|
-
return false;
|
|
397
|
-
value = value[key];
|
|
410
|
+
continue;
|
|
411
|
+
at++;
|
|
398
412
|
}
|
|
399
|
-
return
|
|
413
|
+
return known ? out : null;
|
|
400
414
|
}
|
|
401
415
|
/** One placeholder of a Bun title, or the placeholder as written for a value of another type; null for a JSON Bun shows otherwise. */
|
|
402
416
|
function bunValue(placeholder, value) {
|
package/dist/config-runs.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type ConfigFile, type Configs, type Setting } from './config.ts';
|
|
2
2
|
import { type MochaInterface } from './frameworks/mocha.ts';
|
|
3
3
|
import type { WebdriverIOFramework } from './frameworks/webdriverio.ts';
|
|
4
|
+
import type { PlaywrightSelection } from './scan-file.ts';
|
|
4
5
|
import type { ImportMap } from './resolve.ts';
|
|
5
6
|
import type { FileConfig, VitestTags } from './records.ts';
|
|
6
|
-
import type { Framework, ProjectRecord } from './types.ts';
|
|
7
|
+
import type { Framework, ProjectRecord, SuiteRecord, TestRecord } from './types.ts';
|
|
7
8
|
/** What makes a file run: as a test, or as a Vitest benchmark, which plain `vitest` doesn't run. */
|
|
8
9
|
type Run = 'test' | 'benchmark';
|
|
9
10
|
/**
|
|
@@ -50,9 +51,17 @@ export interface Placement {
|
|
|
50
51
|
candidate?: boolean;
|
|
51
52
|
/** The projects of the config that run the file, which a Playwright `grep` may narrow per test; null when unknown. */
|
|
52
53
|
projects: ProjectAbout[] | null;
|
|
54
|
+
testFilters?: Map<ProjectAbout, RecordFilter>;
|
|
55
|
+
/** Imported modules already initialized in every command that collects this file. */
|
|
56
|
+
preloaded?: Set<string>;
|
|
53
57
|
/** The tags Playwright's config `tag` gives every test; null when the scan can't work them out. */
|
|
54
58
|
tags: string[] | null;
|
|
55
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* A config a package.json script starts the runner with, null for the runner's defaults, the folder it runs from, and
|
|
62
|
+
* for Mocha its command line.
|
|
63
|
+
*/
|
|
64
|
+
type RecordFilter = (test: TestRecord, suites: SuiteRecord[]) => boolean;
|
|
56
65
|
/** Finds the configs a file is under and decides which one runs it, as the runner started at the root would. */
|
|
57
66
|
export declare class ConfigRuns {
|
|
58
67
|
private readonly configs;
|
|
@@ -60,6 +69,9 @@ export declare class ConfigRuns {
|
|
|
60
69
|
private readonly version;
|
|
61
70
|
/** Whether the configs find the test files, as in a scan without patterns, rather than the patterns. */
|
|
62
71
|
private readonly findsFiles;
|
|
72
|
+
private readonly candidates;
|
|
73
|
+
private readonly selection;
|
|
74
|
+
private readonly unfiltered;
|
|
63
75
|
private readonly projects;
|
|
64
76
|
private readonly ignoreRules;
|
|
65
77
|
private readonly folderStates;
|
|
@@ -77,7 +89,7 @@ export declare class ConfigRuns {
|
|
|
77
89
|
/** The projects of a route, by its config and the folder it runs from. */
|
|
78
90
|
private readonly routeProjects;
|
|
79
91
|
private readonly candidateProjects;
|
|
80
|
-
constructor(configs: Configs, framework: Framework, version: [number, number] | null,
|
|
92
|
+
constructor(configs: Configs, framework: Framework, version: [number, number] | null, candidates: readonly string[] | null, selection: (file: string, preloaded?: Set<string>) => PlaywrightSelection);
|
|
81
93
|
/**
|
|
82
94
|
* The config a file uses, as the runner started at the root would: the outermost config at or above it that runs it,
|
|
83
95
|
* with the project that does; else the outermost one whose files the scan can't work out, reported then; else the
|
|
@@ -89,6 +101,7 @@ export declare class ConfigRuns {
|
|
|
89
101
|
* as `vitest --config vitest.integration.config.ts`; when a script's config can't be read, the scan can't tell.
|
|
90
102
|
*/
|
|
91
103
|
private place;
|
|
104
|
+
private scriptRoutesAbove;
|
|
92
105
|
private placeByConfigs;
|
|
93
106
|
/** Retains candidates without claiming a project runs them when the runner constructs its projects at runtime. */
|
|
94
107
|
private unknownPlacement;
|
|
@@ -105,6 +118,10 @@ export declare class ConfigRuns {
|
|
|
105
118
|
* names as their root, else the script's, and read a config path from there; the others read it from the script's.
|
|
106
119
|
*/
|
|
107
120
|
private routesIn;
|
|
121
|
+
/** A process initializes each imported module in the first spec that loads it, in project and directory order. */
|
|
122
|
+
private preloadedModules;
|
|
123
|
+
private unfilteredModules;
|
|
124
|
+
private matchScriptFiles;
|
|
108
125
|
/**
|
|
109
126
|
* The config a runner started in a folder without one named finds: there only, except that Vitest before 5.0 also
|
|
110
127
|
* looks in the folders above it, and Jest takes the folder's package.json when it finds no config; null for Vitest's
|