Skip to content

Getting started ​

test-inventory reads JavaScript and TypeScript test files and lists the tests in them as JSON. It parses the code and never runs it, so it needs no browsers, no build and no configuration of the test runner.

0.1 supports Playwright 1.42 and newer and Vitest 3.0 and newer. It needs Node.js 22.12 or newer, and runs on Linux, macOS and Windows, on x64 and Arm.

Install ​

sh
npm install --save-dev test-inventory

Or try it without adding it to the project. npx downloads the package for one run, after asking:

sh
npx test-inventory "tests/**/*.spec.ts" --framework playwright --output inventory.json

Scan a Playwright suite ​

Take a spec from the UI tests of a trading app, tests/orders/limit-orders.spec.ts:

ts
import { test, expect } from '../../fixtures/index';
import { TAGS } from '../../test-data/tags';

test.describe('orders', { tag: '@orders' }, () => {
  test.describe('limit orders', () => {
    // ...
    // FIXME: TRD-412 the confirm dialog stays open on WebKit
    test(
      'rejects a limit price far from the last trade',
      { annotation: { type: 'issue', description: 'TRD-412' } },
      async ({ browserName, orderTicket }) => {
        test.fixme(browserName === 'webkit', 'confirm dialog stays open on WebKit');
        await orderTicket.buy({ quantity: 1, limitPrice: 1 });
        await expect(orderTicket.error).toHaveText('Limit price is more than 50% away from the last trade.');
      },
    );
  });
});

Run the scan from the project root:

sh
npx test-inventory "tests/**/*.spec.ts" --framework playwright --pretty --output inventory.json

The test's record in inventory.json, shortened:

json
{
  "id": "da2f5749ba9ab068",
  "relativeFilePath": "tests/orders/limit-orders.spec.ts",
  "lineStart": 24,
  "lineEnd": 32,
  "fullName": "orders > limit orders > rejects a limit price far from the last trade",
  "state": "fixme",
  "isFixme": true,
  "isConditional": true,
  "condition": "browserName === 'webkit'",
  "reason": "confirm dialog stays open on WebKit",
  "stateSource": "test",
  "stateLine": 28,
  "tags": ["@orders"],
  "annotations": [{ "type": "issue", "description": "TRD-412", "lineStart": 26 }],
  "comments": ["FIXME: TRD-412 the confirm dialog stays open on WebKit"]
}

The test imports test from a local fixtures file. The scan follows that one import to check that it exports a Playwright test object created with test.extend().

Scan a Vitest suite ​

sh
npx test-inventory "tests/**/*.{test,test-d}.ts" "src/**/*.ts" --framework vitest --output inventory.json

Include the source files when they contain in-source tests, and the *.test-d.ts files for type tests.

Next ​


If test-inventory turns out to be useful to you, sponsoring its development pays for the time that keeps it current with new Playwright and Vitest versions.