Compact JSONL output format for ExUnitJSON.
Provides functionality for the --compact option, which outputs one JSON
object per line with minimal fields for efficient streaming and parsing.
Format
Each test is output as a single line JSON object with compact keys:
f- File path with line number (e.g., "test/my_test.exs:42")n- Test names- Test state (passed, failed, skipped, excluded, invalid)e- Error message first line (only for failed tests)x- Filtered flag (only when true)
The last line is a summary object: {"summary": {...}}
Summary
Functions
Builds compact JSONL output from tests and summary.
Encodes a single test as a compact JSON object.
Types
Functions
@spec build_compact_output([encoded_test()] | nil, summary(), keyword()) :: iodata()
Builds compact JSONL output from tests and summary.
Returns iodata with one JSON object per line, ending with summary.
Examples
tests = [%{name: "test", file: "test.exs", line: 1, state: "passed", ...}]
summary = %{total: 1, passed: 1, ...}
build_compact_output(tests, summary, [])
#=> "{\"f\":\"test.exs:1\",\"n\":\"test\",\"s\":\"passed\"}\n{\"summary\":{...}}\n"
@spec encode_compact_test(encoded_test()) :: String.t()
Encodes a single test as a compact JSON object.
Keys
f- file:linen- names- statee- error (first line only, only if failed)x- filtered (only if true)
Examples
test = %{file: "test.exs", line: 10, name: "passes", state: "passed", failures: []}
encode_compact_test(test)
#=> "{\"f\":\"test.exs:10\",\"n\":\"passes\",\"s\":\"passed\"}"