# Command tests
Optional `tests:` on any command node. Names must follow `given_…_when_…_then_…` (spaces or hyphens are fine). `jan test <path>` runs that node and every nested descendant.
```yaml
commands:
android:
commands:
skills:
commands:
list:
about: List skills (demo)
exec:
argv: ["echo", "jan", "android", "skills", "list"]
tests:
given_no_args_when_listed_then_prints_path:
then: |
test "$JAN_STATUS" -eq 0
printf '%s\n' "$JAN_STDOUT" | grep -q "jan android skills list"
```
## Fields
| `given` | Optional setup (files, fixtures). Runs in a temp dir as POSIX `sh`. |
| `when` | Extra argv for the command the test is declared on. **Do not** repeat the script path. Omit to invoke that command with no extra args. |
| `then` | Required. Assertions against the captured result and any files from `given`. |
`when` is extra argv only — jan already knows which command the test hangs off.
## Captured environment for `then`
| `JAN_STATUS` | Exit code of the `when` invocation |
| `JAN_STDOUT` | Captured stdout |
| `JAN_STDERR` | Captured stderr |
Result lines print the script path and the test name (`ok` / `not ok`). `jan test` never writes the audit log (`--no-log` is implied, including nested `jan` invocations).
CLI: [`jan test`](../cli/test.md).