Test Inventory

v0.13.0
io.github.Huldoser/test-inventory Checked 9 hours ago Published 2 days ago

Discover tests, skip reasons and affected tests, and compare inventories without running tests.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

test_summary Test summary

Counts a project's tests by state (active, skip, fixme, todo, expectedToFail, notLoaded) and by tag and annotation, from the test files, without running them. Use it first, for questions such as how many tests are skipped, or which files or tags have the most skipped tests; use find_tests to list the tests themselves. states, tags and grep count only the tests they match. groupBy "file", "tag" or "project" adds the counts of each, sorted by name and paged with limit and cursor; a test with no tag is in no tag group, and one whose projects the scan cannot tell in no project group. configs lists…

ParameterTypeDescription
cursorstringnextCursor from the previous answer, for the next page. Keep the other arguments the same.
directorystringA folder inside the project to scan, relative to its root, such as "packages/web". Default: the root.
expandCasesbooleanLists each case of a .each or .for table and each pass of a loop as its own test, with the name the runner gives it and caseIndex, as the runner registers them. Ids differ from those without it, so pa…
frameworkstringThe test runner. Default: the one the server was started with, otherwise the one the project in `directory` uses.
grepstringKeeps tests whose fullName (describe titles and title joined with " > ") matches this regular expression, ignoring case.
groupBystringAdds the counts of each file, tag or project.
limitintegerThe most items to return.
patternsarrayGlobs of the test files, relative to `directory`, such as ["tests/**/*.spec.ts"]. Default: the ones the server was started with, or without them the files the configs in `directory` and below it run.
relatedarrayChanged files, relative to the project root as `git diff --name-only` writes them, such as ["pages/order-ticket.ts"]. Keeps tests that list a changed dependency, match a changed file through dependenc…
statesarrayKeeps tests in one of these states.
tagsarrayKeeps tests with one of these tags, written as in the titles, such as "@smoke".

find_tests Find tests

Lists a project's tests that match filters, read from the test files without running them: each with its id, full name, file and line, state, skip reason and condition, and tags by default. Use it for questions such as which tests are skipped and why, which tests carry @smoke, where a .only was left in, or which tests a change can affect (related, the changed files); use test_summary for counts and get_tests for every key of a few ids. projects keeps the tests one of the named projects runs, after each project's grep, leaving out tests whose projects the scan cannot tell. Filters combine with…

ParameterTypeDescription
cursorstringnextCursor from the previous answer, for the next page. Keep the other arguments the same.
directorystringA folder inside the project to scan, relative to its root, such as "packages/web". Default: the root.
expandCasesbooleanLists each case of a .each or .for table and each pass of a loop as its own test, with the name the runner gives it and caseIndex, as the runner registers them. Ids differ from those without it, so pa…
fieldsarrayKeys of each test record to return, besides id. Default: fullName, relativeFilePath, lineStart, state, reason, condition, tags.
frameworkstringThe test runner. Default: the one the server was started with, otherwise the one the project in `directory` uses.
grepstringKeeps tests whose fullName (describe titles and title joined with " > ") matches this regular expression, ignoring case.
limitintegerThe most items to return.
onlybooleantrue keeps tests that use .only, or are in a describe that does.
patternsarrayGlobs of the test files, relative to `directory`, such as ["tests/**/*.spec.ts"]. Default: the ones the server was started with, or without them the files the configs in `directory` and below it run.
projectsarrayKeeps tests that one of these projects runs, named as in the configs test_summary lists.
relatedarrayChanged files, relative to the project root as `git diff --name-only` writes them, such as ["pages/order-ticket.ts"]. Keeps tests that list a changed dependency, match a changed file through dependenc…
statesarrayKeeps tests in one of these states.
tagsarrayKeeps tests with one of these tags, written as in the titles, such as "@smoke".
unconditionalbooleanKeeps tests whose effective state has no condition.
withoutReasonbooleantrue keeps non-active tests without a reason, including expected failures; excludes notLoaded.

get_tests Get tests

Returns every key of the tests with the given ids, with the scan diagnostics about them, read from the test files without running them: location, describe path, state and where it is set, condition, reason, tags, annotations, comments above the test, parameters, the projects that run it, hooks around it, timeout and retries with where each is set (the test, a describe, the file or the config), fixtures, expect() counts, steps, body hash, and the files the test runs with dependencyHash. Use it after find_tests or test_summary, for the details of up to 20 tests. Ids come from find_tests and stay…

ParameterTypeDescription
ids *arrayTest ids, as find_tests returns them.
directorystringA folder inside the project to scan, relative to its root, such as "packages/web". Default: the root.
expandCasesbooleanLists each case of a .each or .for table and each pass of a loop as its own test, with the name the runner gives it and caseIndex, as the runner registers them. Ids differ from those without it, so pa…
frameworkstringThe test runner. Default: the one the server was started with, otherwise the one the project in `directory` uses.
patternsarrayGlobs of the test files, relative to `directory`, such as ["tests/**/*.spec.ts"]. Default: the ones the server was started with, or without them the files the configs in `directory` and below it run.

scan_diagnostics Scan diagnostics

Lists the problems test-inventory found while reading the test files: level error means tests may be missing from the other answers (a file that failed to parse, an import it could not follow), or that the runner fails the file or the run (a Vitest tag the config does not define, a .only that forbidOnly fails); level warning means a value is missing or approximate (a title built at run time, a config value computed at run time, a file no config runs). They are about reading the code, not test failures. Use it when another tool reports scanErrors, or to check why a test is missing or notLoaded.…

ParameterTypeDescription
codesarrayKeeps problems with these codes.
cursorstringnextCursor from the previous answer, for the next page. Keep the other arguments the same.
directorystringA folder inside the project to scan, relative to its root, such as "packages/web". Default: the root.
expandCasesbooleanLists each case of a .each or .for table and each pass of a loop as its own test, with the name the runner gives it and caseIndex, as the runner registers them. Ids differ from those without it, so pa…
frameworkstringThe test runner. Default: the one the server was started with, otherwise the one the project in `directory` uses.
levelsarrayKeeps problems of these levels.
limitintegerThe most items to return.
pathstringKeeps problems in this file, or in the files under this folder, relative to `directory`.
patternsarrayGlobs of the test files, relative to `directory`, such as ["tests/**/*.spec.ts"]. Default: the ones the server was started with, or without them the files the configs in `directory` and below it run.

diff_inventories Diff inventories

Compares two complete saved JSON scans inside the project, without running tests or changing files. Reports additions, removals, renames, moves, code and dependency changes, states, tags and other metadata. Uses ids first, then unique body hashes and file, suite or dependency context; ambiguous matches remain added and removed. Use the same framework, root, patterns, filters and expandCases for both saved scans. Hash comparisons and rename matching are disabled across tool versions. Follow nextCursor for more changes. For Playwright, Vitest, Jest, Mocha, Jasmine, Cypress, WebdriverIO, node:tes…

ParameterTypeDescription
after *stringThe new complete JSON inventory, relative to the project root; at most 128 MiB.
before *stringThe old complete JSON inventory, relative to the project root; at most 128 MiB.
cursorstringnextCursor from the previous answer, for the next page. Keep the other arguments the same.
limitintegerThe most items to return.

get_run_commands Get test run commands

Returns POSIX shell commands for test files related to the changed paths. Run them from the scanned directory. Each command gives its config, projects, files and any runner caveat. A runner can run more tests than the matched declarations. The server only returns commands. Follow nextCursor for more.

ParameterTypeDescription
related *arrayChanged files relative to the server root, as git diff --name-only writes them.
cursorstringnextCursor from the previous answer, for the next page. Keep the other arguments the same.
directorystringA folder inside the project to scan, relative to its root, such as "packages/web". Default: the root.
expandCasesbooleanLists each case of a .each or .for table and each pass of a loop as its own test, with the name the runner gives it and caseIndex, as the runner registers them. Ids differ from those without it, so pa…
frameworkstringThe test runner. Default: the one the server was started with, otherwise the one the project in `directory` uses.
limitintegerThe most items to return.
patternsarrayGlobs of the test files, relative to `directory`, such as ["tests/**/*.spec.ts"]. Default: the ones the server was started with, or without them the files the configs in `directory` and below it run.