test-inventory 0.12.1 → 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 +141 -0
- package/README.md +74 -49
- 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 +379 -90
- 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/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 +4 -1
- package/dist/node-scripts.js +77 -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 +2 -2
- package/schema/v1.json +1 -0
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
|