# _snapshot

URL: /milo-cli/api/milo/testing/_snapshot/
Section: testing
Description: Snapshot capture and comparison.

---

> For a complete page index, fetch /milo-cli/llms.txt.

Open LLM text
(/milo-cli/api/milo/testing/_snapshot/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_snapshot%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_snapshot%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_snapshot%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_snapshot%2Findex.txt)

Module

#
`testing._snapshot`

Snapshot capture and comparison.

4Functions

## Functions

`strip_ansi`

1

`str`

▼

Remove ANSI escape sequences from text.

`def strip_ansi(text: str) -> str`

##### Parameters

Name
Type
Description

`text`
`str`

##### Returns

`str`

`assert_renders`

7

`str`

▼

Render state through template, assert output matches snapshot.

If snapshot is …

`def assert_renders(state: Any, template: str | Any, *, snapshot: str | Path | None = None, width: int = 80, color: bool = False, update: bool = False, env: Any = None) -> str`

Render state through template, assert output matches snapshot.

If snapshot is None, returns rendered string.
If snapshot is a path and doesn't exist, creates it.
If update=True, overwrites on mismatch.

##### Parameters

Name
Type
Description

`state`
`Any`

`template`
`str | Any`

`snapshot`
`str | Path | None`

Default:`None`

`width`
`int`

Default:`80`

`color`
`bool`

Default:`False`

`update`
`bool`

Default:`False`

`env`
`Any`

Default:`None`

##### Returns

`str`

`assert_state`

4

`None`

▼

Feed actions through reducer, assert final state matches.

`def assert_state(reducer: Any, initial: Any, actions: list | tuple, expected: Any) -> None`

##### Parameters

Name
Type
Description

`reducer`
`Any`

`initial`
`Any`

`actions`
`list | tuple`

`expected`
`Any`

`assert_saga`

2

`None`

▼

Step through saga, assert each yielded effect matches.

`def assert_saga(saga: Any, steps: list[tuple[Any, Any]]) -> None`

##### Parameters

Name
Type
Description

`saga`
`Any`

`steps`
`list[tuple[Any, Any]]`
