test-inventory 0.4.1 → 0.6.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +4 -1
  3. package/dist/ast.d.ts +3 -3
  4. package/dist/ast.js +4 -4
  5. package/dist/bin.js +1 -0
  6. package/dist/cli.d.ts +4 -2
  7. package/dist/cli.js +27 -7
  8. package/dist/config-dependencies.d.ts +62 -0
  9. package/dist/config-dependencies.js +231 -0
  10. package/dist/config-runs.d.ts +113 -0
  11. package/dist/config-runs.js +807 -0
  12. package/dist/config.d.ts +90 -0
  13. package/dist/config.js +652 -0
  14. package/dist/dependency-hash.d.ts +242 -0
  15. package/dist/dependency-hash.js +1458 -0
  16. package/dist/diagnostics.js +6 -1
  17. package/dist/extract.d.ts +20 -0
  18. package/dist/extract.js +20 -4
  19. package/dist/filter.d.ts +6 -0
  20. package/dist/filter.js +18 -1
  21. package/dist/frameworks/bindings.d.ts +22 -0
  22. package/dist/frameworks/bindings.js +19 -9
  23. package/dist/frameworks/common.d.ts +5 -0
  24. package/dist/frameworks/common.js +11 -0
  25. package/dist/frameworks/playwright.d.ts +2 -1
  26. package/dist/frameworks/playwright.js +11 -2
  27. package/dist/frameworks/vitest.d.ts +2 -1
  28. package/dist/frameworks/vitest.js +9 -3
  29. package/dist/hash.d.ts +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/inventory.d.ts +2 -2
  32. package/dist/inventory.js +2 -1
  33. package/dist/json.js +2 -0
  34. package/dist/model.d.ts +9 -1
  35. package/dist/options.d.ts +2 -2
  36. package/dist/records.d.ts +58 -2
  37. package/dist/records.js +196 -28
  38. package/dist/scan-file.d.ts +13 -1
  39. package/dist/scan-file.js +16 -4
  40. package/dist/scan-source.js +1 -1
  41. package/dist/scan.d.ts +2 -1
  42. package/dist/scan.js +131 -18
  43. package/dist/types.d.ts +83 -7
  44. package/dist/values.d.ts +5 -0
  45. package/dist/values.js +5 -0
  46. package/dist/vitest-config.d.ts +6 -4
  47. package/dist/vitest-config.js +32 -28
  48. package/dist/vitest-defaults.d.ts +6 -0
  49. package/dist/vitest-defaults.js +16 -0
  50. package/package.json +10 -8
  51. package/schema/v1.json +200 -6
@@ -0,0 +1,113 @@
1
+ import { type ConfigFile, type Configs, type Setting } from './config.ts';
2
+ import type { FileConfig, VitestTags } from './records.ts';
3
+ import type { Framework, ProjectRecord } from './types.ts';
4
+ /** What makes a file run: as a test, or as a Vitest benchmark, which plain `vitest` doesn't run. */
5
+ type Run = 'test' | 'benchmark';
6
+ /**
7
+ * What the output says of a project: its name, the folder its test files are found from and Playwright's
8
+ * `dependencies`. `grep` is Playwright's filter of its test titles, which start from the path in `grepRoot`.
9
+ */
10
+ export interface ProjectAbout {
11
+ name: string;
12
+ testDir: string;
13
+ dependencies: string[];
14
+ /** The project's settings, which its setup files are read from. */
15
+ settings: Setting;
16
+ /** The folder its setup files are found from: Vitest's root, or the config's folder. */
17
+ root: string;
18
+ /** For a Vitest project from a config another config lists, the outermost one, whose global setup runs too. */
19
+ container: ConfigFile | null;
20
+ /** The config the project is written in. */
21
+ config: ConfigFile;
22
+ grep: ((title: string) => boolean) | null;
23
+ grepRoot: string;
24
+ defaults: ProjectDefaults;
25
+ }
26
+ /**
27
+ * The settings a project gives its tests, as written; null when unset. Playwright's `timeout`, `retries`, `repeatEach`
28
+ * and `fullyParallel`; Vitest's `testTimeout`, `retry`, `repeats` and `sequence.concurrent`, and the tags it defines.
29
+ */
30
+ interface ProjectDefaults {
31
+ timeout: Setting | null;
32
+ retry: Setting | null;
33
+ repeatEach: Setting | null;
34
+ repeats: Setting | null;
35
+ parallel: Setting | null;
36
+ tags: VitestTags | null;
37
+ }
38
+ /** The config a file uses, the settings of its project, and how that config runs it. */
39
+ export interface Placement {
40
+ config: ConfigFile | null;
41
+ settings: Setting | null;
42
+ /** False when no config runs the file; null when there is no config, or one can't tell. */
43
+ runs: Run | false | null;
44
+ /** The projects of the config that run the file, which a Playwright `grep` may narrow per test; null when unknown. */
45
+ projects: ProjectAbout[] | null;
46
+ }
47
+ /** Finds the configs a file is under and decides which one runs it, as the runner started at the root would. */
48
+ export declare class ConfigRuns {
49
+ private readonly configs;
50
+ private readonly framework;
51
+ private readonly version;
52
+ /** Whether the configs find the test files, as in a scan without patterns, rather than the patterns. */
53
+ private readonly findsFiles;
54
+ private readonly projects;
55
+ private readonly ignoreRules;
56
+ private readonly folderStates;
57
+ /** The Vitest configs whose projects are being found, to stop at one whose projects name itself. */
58
+ private readonly expanding;
59
+ constructor(configs: Configs, framework: Framework, version: [number, number] | null, findsFiles: boolean);
60
+ /**
61
+ * The config a file uses, as the runner started at the root would: the outermost config at or above it that runs it,
62
+ * with the project that does; else the outermost one whose files the scan can't work out, reported then; else the
63
+ * nearest config.
64
+ */
65
+ placementOf(file: string): Placement;
66
+ /** The projects of a config the output lists; null when the scan can't work them out. */
67
+ projectsIn(config: ConfigFile): ProjectRecord[] | null;
68
+ /**
69
+ * A config's project, named as the runner names it, with the files it runs; null when there is none, or the scan
70
+ * can't tell which files it runs.
71
+ */
72
+ projectNamed(config: ConfigFile, name: string): {
73
+ about: ProjectAbout;
74
+ runs: (file: string) => unknown;
75
+ } | null;
76
+ private projectsOf;
77
+ /** Vitest's `retry`: before 4.1, which reads only a count, an object is one the scan can't work out. */
78
+ private vitestRetry;
79
+ /** A project whose files can't be worked out, because of `setting` under `key`: it may run any file. */
80
+ private unknownProject;
81
+ private playwrightProjects;
82
+ /** A Playwright project: its own settings, else the config's, else Playwright's defaults. */
83
+ private playwrightProject;
84
+ /**
85
+ * Whether `.gitignore` files in a project's test folder, and the folders below it on the way to the file, leave the
86
+ * file out, as Playwright reads them.
87
+ */
88
+ private isGitIgnored;
89
+ /** A folder's status and the rules inside it, worked out once per project folder however many files it holds. */
90
+ private folderState;
91
+ private rulesIn;
92
+ private vitestProjects;
93
+ /** A project written in `test.projects`, which inherits the root config as each version of Vitest decides. */
94
+ private vitestEntry;
95
+ /**
96
+ * The projects of a config file or folder `test.projects` names: the config's own, also the projects it lists in
97
+ * Vitest 5, or a project with Vitest's defaults for a folder without a config.
98
+ */
99
+ private vitestPath;
100
+ /**
101
+ * A Vitest project: its files are found from `test.dir`, else `test.root` or `root`, else its folder. With browser
102
+ * mode on, each of `browser.instances` is a project of its own, named as Vitest names it.
103
+ */
104
+ private vitestProject;
105
+ /** The files a Vitest project runs and its settings; `ownTags`, when set, in place of the tags in `settings`. */
106
+ private vitestFiles;
107
+ }
108
+ /**
109
+ * What the config a file uses gives it: Playwright's `forbidOnly`, read from the top level only, as Playwright reads
110
+ * it, and for each test, the projects that run it and what they set; null without a config.
111
+ */
112
+ export declare function fileConfig(placement: Placement, framework: Framework, version: [number, number] | null, file: string): FileConfig | null;
113
+ export {};