nika test <file> runs the workflow
under the mock provider — offline, deterministic, zero keys, zero
tokens — and compares the typed outputs: against a golden file
(<file>.golden.json) committed next to it. Same idea as snapshot testing:
pin what the workflow produces, and any future edit that changes the
contract fails loud in CI.
Why the mock makes this possible
nika test swaps every infer: / agent: call to the mock provider,
whatever model: the file declares — your ollama/llama3.2:3b (or
mistral/…, or any cloud model) workflow tests offline, unchanged.
The mock is not a stub that returns "ok". It is schema-conformant:
when a task declares a schema:, the mock synthesizes an instance that
validates against it — required fields present, types respected. Every
schema workflow runs offline, end to end, through the same runtime,
bindings, and typed-outputs validation as a live run.
triage.nika.yaml
The golden lifecycle
First run — no golden exists yet, sonika test teaches instead of
guessing (exit 3):
--update, review it once, commit it:
triage.nika.yaml.golden.json
nika test compares. A match is exit 0; drift renders a
per-path diff and exits 1:
--update and commit the new golden — the diff shows up in code
review, exactly like a snapshot test.
Exit codes · the CI contract
| Exit | Meaning |
|---|---|
0 | Outputs match the golden (or --update pinned one) |
1 | The mock run failed, or outputs drifted from the golden |
2 | The file has validation findings (nika check would fail — fix those first) |
3 | No golden yet (create with --update), or environment error |
nika test refuses to run a dirty file the same way nika run does: a
workflow with check findings exits 2 before anything executes.
Wire it into CI
Offline and deterministic means no keys in CI, no flakes, no spend:.github/workflows/nika-test.yml (fragment)
*.golden.json files in the same directory as the workflows
they guard. A PR that edits a workflow either keeps its golden green or
shows the re-pinned golden in the diff — both are reviewable.
Related
- Concepts · Workflows: typed
vars:in, typedoutputs:out — the callable contract the golden pins. - Reference · CLI: every
nika testflag. - Guides · Troubleshooting: when
nika checkfindings block a test (exit 2).