test-inventory 0.2.0 → 0.3.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/dist/resolve.js CHANGED
@@ -267,7 +267,12 @@ function workspacePackages(directory) {
267
267
  const workspaces = readJson(path.join(folder, 'package.json'))?.workspaces;
268
268
  const fromManifest = Array.isArray(workspaces) ? workspaces : record(workspaces)?.packages;
269
269
  const pnpm = readText(path.join(folder, 'pnpm-workspace.yaml'));
270
- const patterns = (Array.isArray(fromManifest) ? fromManifest : pnpm ? pnpmWorkspacePatterns(pnpm) : null)?.filter((item) => typeof item === 'string');
270
+ // pnpm reads only pnpm-workspace.yaml, and npm, Yarn and Bun only package.json, so a repository that moved to
271
+ // pnpm may still have an old list there. Packages from both are found.
272
+ const lists = [Array.isArray(fromManifest) ? fromManifest : null, pnpm ? pnpmWorkspacePatterns(pnpm) : null];
273
+ const patterns = lists.some((list) => list !== null)
274
+ ? lists.flat().filter((item) => typeof item === 'string')
275
+ : null;
271
276
  if (patterns) {
272
277
  // Packages are inside the workspace. A pattern or a link that leads out of its folder could send the search through
273
278
  // the whole disk, so neither is followed.
package/dist/types.d.ts CHANGED
@@ -49,6 +49,22 @@ export interface Inventory {
49
49
  tests: TestRecord[];
50
50
  diagnostics: Diagnostic[];
51
51
  }
52
+ /**
53
+ * One line of the JSON Lines output (`--format jsonl`): the inventory with each record on its own line, marked by
54
+ * `type`. The `inventory` line comes first, then the suites, tests and diagnostics in the order of the JSON output,
55
+ * and the `summary` line last.
56
+ */
57
+ export type InventoryLine = ({
58
+ type: 'inventory';
59
+ } & Pick<Inventory, 'schemaVersion' | 'tool' | 'framework' | 'frameworkVersion'>) | ({
60
+ type: 'suite';
61
+ } & SuiteRecord) | ({
62
+ type: 'test';
63
+ } & TestRecord) | ({
64
+ type: 'diagnostic';
65
+ } & Diagnostic) | ({
66
+ type: 'summary';
67
+ } & Summary);
52
68
  /** @inline */
53
69
  export interface Tool {
54
70
  name: 'test-inventory';
@@ -219,7 +235,7 @@ export interface TestRecord {
219
235
  caseCount: Count | null;
220
236
  /** Declared inside a loop, `forEach` or `map`. */
221
237
  isInLoop: boolean;
222
- /** Declared inside `if`, `?:`, `&&` or `switch`. */
238
+ /** Declared inside `if`, `?:`, `&&`, `switch` or a `catch` block. */
223
239
  isInCondition: boolean;
224
240
  /** Declared inside a plain function. */
225
241
  isInFunction: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-inventory",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Test metadata from source code, not from test results.",
5
5
  "keywords": [
6
6
  "testing",
@@ -71,7 +71,7 @@
71
71
  "lint": "eslint .",
72
72
  "lint:fix": "eslint . --fix",
73
73
  "format": "prettier --write . --ignore-path .gitignore --ignore-path .prettierignore --ignore-path .git/info/exclude",
74
- "format:check": "prettier --check . --ignore-path .gitignore --ignore-path .prettierignore --ignore-path .git/info/exclude",
74
+ "format:check": "node scripts/format-check.ts",
75
75
  "docs:api": "typedoc",
76
76
  "docs:dev": "npm run docs:api && vitepress dev docs",
77
77
  "docs:build": "npm run docs:api && vitepress build docs",
package/schema/v1.json CHANGED
@@ -730,7 +730,7 @@
730
730
  },
731
731
  "isInCondition": {
732
732
  "type": "boolean",
733
- "description": "Declared inside `if`, `?:`, `&&` or `switch`."
733
+ "description": "Declared inside `if`, `?:`, `&&`, `switch` or a `catch` block."
734
734
  },
735
735
  "isInFunction": {
736
736
  "type": "boolean",