# `ExUnitJSON.CompactOutput`
[🔗](https://github.com/ZenHive/ex_unit_json/blob/main/lib/ex_unit_json/compact_output.ex#L1)

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 name
- `s` - 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": {...}}`

# `encoded_test`

```elixir
@type encoded_test() :: map()
```

A JSON-encoded test result map

# `summary`

```elixir
@type summary() :: map()
```

Summary statistics map

# `build_compact_output`

```elixir
@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"

# `encode_compact_test`

```elixir
@spec encode_compact_test(encoded_test()) :: String.t()
```

Encodes a single test as a compact JSON object.

## Keys

- `f` - file:line
- `n` - name
- `s` - state
- `e` - 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\"}"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
