SmartTest

Public contracts

SmartTest follows semantic versioning from 1.0.0. This page lists what is public, so that scripts, CI pipelines, editors and plugins can rely on it, and which changes need a major version.

What is frozen at 1.0.0 #

ContractWhere it is definedChecked by
Configuration fileconfig.v1.schema.json, configuration referencepackages/config/src/schema.test.ts (schema = type = validator)
Exit codes and categoriesExit codes below, packages/shared/src/errors.tspackages/shared/src/errors.test.ts, integration-tests/contracts.test.ts
--json documentsOne <command>.v1.schema.json per frozen command in packages/cli/schemas/integration-tests/contracts.test.ts validates real CLI output
Error documenterror.v1.schema.jsonintegration-tests/contracts.test.ts
Plugin SDK v1@tkmremi/smarttest/plugin-sdk, @tkmremi/smarttest/plugin-sdk/conformance (Plugins guide)the conformance kit, run against every built-in adapter
Commands and flagsCLI referenceintegration-tests/docs.test.ts parses every documented command line

The schemas ship in the package: node_modules/@tkmremi/smarttest/schemas/<name>.v1.schema.json, also importable as @tkmremi/smarttest/schemas/<name>.v1.schema.json.

@tkmremi/smarttest/studio exports startStudio(options) (Studio guide): its options and handle follow the semver policy below, while what Studio shows is not a contract.

Not public, and free to change in any release: everything under .smarttest/ (index, graph, traces, history, caches, logs; SmartTest rebuilds what it cannot read), the HTML report's layout, human-readable terminal output, log messages, and the @smarttest/* workspace packages, which are bundled into smarttest and not published.

--json documents #

With --json, a command prints exactly one JSON document on stdout; logs and progress go to stderr. Every document has "schemaVersion": 1 and "command". When the command fails, the document is the error document instead, and the exit code follows its category.

CommandSchemaNotes
runrun.v1.schema.jsonsmarttest ci --json (without --dry-run) prints this document too
impactimpact.v1.schema.json
scanscan.v1.schema.json
explainexplain.v1.schema.jsonkind is test or source; units with --units
ci --dry-runci.v1.schema.jsonThe comparison plan
doctordoctor.v1.schema.json
shardshard.v1.schema.json
flakyflaky.v1.schema.json
validate-selectionvalidate-selection.v1.schema.json
hook status/install/uninstallhook.v1.schema.jsonOne of three shapes, one per subcommand
syncsync.v1.schema.json
any command, on failureerror.v1.schema.jsonerror.code, error.category, error.message, optional error.hint

run --hook --json adds a hook object to the run document. When the hook ran nothing (bypassed with SMARTTEST_SKIP=1, hook.skipped: true, or a push that only deletes remote refs, hook.nothingPushed: true), the document has schemaVersion, command and hook only: there is no report, and nothing is reported as passed.

trace, shadow, migrate, init, uninstall, generate, rules, snapshot, vcs, benchmark, audit, graph, coverage, report and studio also accept --json. Their documents carry schemaVersion: 1 but are experimental: their shape may change in a minor release. A test fails when a command starts printing JSON without being listed as frozen or experimental.

Consumers should ignore fields they do not know and tolerate new values in enumerations of output fields (a new selection reason kind, a new doctor check).

Exit codes #

CodeCategoryMeaning
0—Success
1test-failureA test failed, timed out or was cancelled
2usageUnknown command or flag, bad argument
3configurationInvalid configuration or plugin, rule conflict, confirmation required
4infrastructureA runner, the version control or an edge provider failed; a base ref is missing
5policyA safety check found a missed failure; a rollback would overwrite edited files
70internalA SmartTest bug

Errors also carry a stable code such as ST_CONFIG_INVALID or ST_GIT_BASE_MISSING. A code is never renamed, reused for another condition, or moved to another category within a major version.

A write that needs confirmation and gets neither --yes nor a prompt (non-interactive, or --json) exits 3 with ST_INIT_CONFIRMATION_REQUIRED (init, sync, migrate), ST_HOOK_CONFIRMATION_REQUIRED (hook install, hook uninstall; 0.x used ST_INIT_CONFIRMATION_REQUIRED there) or ST_CONFIRMATION_REQUIRED (uninstall).

Semver policy #

Breaking, only in a major version (2.0.0):

Not breaking, in a minor or patch release:

Deprecation: something deprecated keeps working and warns (a configuration warning, deprecated in the schema, a note in --help) for at least one minor version, and is removed only in the next major. A future breaking change to a document ships as <command>.v2.schema.json with schemaVersion: 2.

Migrating from 0.x #

No configuration key was renamed or removed between 0.1 and 1.0, so a 0.x configuration keeps its meaning. Run smarttest doctor and smarttest sync --check after upgrading. (smarttest migrate --to vitest moves Jest projects to Vitest; it is not needed for the upgrade.)

What can change for you:

Edit this page on GitHub