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/PMN123/trapdoor --skill jac-testing-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-testing
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-testing
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-testing-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing and debugging tests in the Jac language involves non-obvious behaviors: tests share a persisted graph root across runs, file naming rules collide with Python's test machinery, and walker assertions require spawn plus .reports semantics. This Skill provides the verified patterns and pitfalls so tests are written correctly the first time. ## Core Features & Use Cases - Test authoring patterns: Covers test "name" { } blocks, assert statements, exception testing via try/except, and parameterized tests with parametrize(). - Test execution guidance: Documents jac test flags (-t, -f, -x, -m, -v), [test] config in jac.toml, and the two file-naming traps (test_*.jac prefix and .test.jac annex modules). - Graph state and walker testing: Explains the shared persisted root, the jac clean fix for stale state, and asserting walker output via spawn and result.reports. - Use Case: A developer's previously green Jac test suite fails on re-run with NodeAnchor is not a valid reference; this Skill identifies the stale persisted graph as the cause and prescribes jac clean --all --force plus defensive node-count assertions. ## Quick Start Ask the assistant to write a Jac test that spawns a walker and asserts on its reports, following the jac-testing skill's patterns.

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 the Jac language?

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

How do I test a Jac walker and check its reports?

Spawn the walker inside a test with `result = root spawn MyWalker();` and assert on `result.reports`, a list of everything the walker reported in order. You can also assert graph shape directly, such as `assert len([root-->]) == 2;`.

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

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

Why does my Jac test file fail with No module named error?

A `.test.jac` file is an annex that must pair with a same-basename module, so `people.test.jac` requires `people.jac` and runs via `jac test people.jac`. Also avoid the `test_` filename prefix, which collides with Python's test-module import machinery.

How do I test Jac endpoints without starting a server?

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

How do I test Jac functions that call an LLM?

Do not hit a real model in tests; use MockLLM with canned outputs so results are deterministic. This pairs with the jac-by-llm skill, which documents MockLLM configuration for `by llm()` functions.