jac-testing

Write and run tests for Jac programs using test blocks, jac test flags, and JacTestClient.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-testing-nihalnihalani
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-testing
Source: https://github.com/nihalnihalani/jachacks-sf-2026/tree/main/plugins/jac-codex/skills/jac-testing
Command: npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-testing-nihalnihalani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing Jac code has language-specific traps: tests share a persisted graph root across runs, file naming collides with Python's test machinery, and walkers need spawn-based assertions. This Skill provides the correct patterns so test suites stay green and deterministic. ## Core Features & Use Cases - Test authoring patterns: test "name" { } blocks, assert-with-message, try/except for expected exceptions, and parametrize() for data-driven cases. - Walker and graph testing: spawn walkers and assert on .reports, verify graph shape with traversal filters, and handle the shared persisted-root gotcha with jac clean. - Endpoint testing: use JacTestClient from pytest to test walker:pub endpoints in-process with isolated base_path storage. - Use Case: A suite passes locally but fails on re-run with NodeAnchor is not a valid reference — the Skill explains the stale persisted-graph cause and the jac clean --all --force fix. ## Quick Start Write a test block for my walker in main.jac and show me the jac test command to run just that test.

Frequently Asked Questions about jac-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write and run tests in Jac?▼

Write `test "name" { }` blocks alongside your code with plain assert statements, then run `jac test main.jac`. Use `-t "name"` to run one test, `-x` to stop on first failure, and `-v` for verbose output.

How do I test a walker in Jac?▼

Spawn the walker inside a test block with `root spawn MyWalker()` and assert on the returned instance's `.reports` list, which contains every report in order. You can also assert graph shape directly with traversal expressions like `len([root-->])`.

Why do my Jac tests pass once then fail on re-run?▼

Tests share one persisted root, and nodes hung off root persist to `.jac/data` between runs, so stale state contaminates later runs. Run `jac clean --all --force` before testing and write assertions that count only nodes the test itself created.

Can I name Jac test files test_*.jac like Python?▼

No. The `test_` prefix collides with Python's test-module import machinery. Use names like `utils_tests.jac`, or the annex form `<mod>.test.jac` which attaches to a same-basename module and runs via `jac test <mod>.jac`.

How do I test Jac server endpoints without starting a server?▼

Use JacTestClient from `jaclang.runtimelib.testing` inside pytest: create it with `JacTestClient.from_file("app.jac", base_path=tmp_path)`, register a user, and POST to walker endpoints. The `base_path` isolates each test's persisted graph.

How do I test LLM-powered functions in Jac?▼

Avoid hitting a real model in tests. Use MockLLM with canned outputs so `by llm` functions return deterministic responses, keeping test runs fast and reproducible.