Skip to Content
steep

Test with tapes

Run tapes as tests, with waits and golden files, no code needed.

reel test runs tapes without writing their outputs. A tape fails at the first command that does: a Wait that times out, a Snapshot that differs, or any other error.

tests/shop.tape
Set Columns 72
Set Rows 16
Type "teashop" Enter
Wait+Screen "Sencha"
Down
Wait+Screen "Matcha"
Snapshot menu
Type "q"

Here it is with one tape that passes, and one that waits for something that never appears:

$ reel test tests/
FAIL  tests/broken.tape	1.11s
      tape: tests/broken.tape:6:1: wait for /Genmaicha/ on the screen timed out after 500ms; the screen was:
      ╭──────────────────────────────────────────────────────────────────────╮
      │ The Tea Shop                                                         │
      │                                                                      │
      │  Sencha                                                 green    1m  │
      │  Matcha                                                 green    0m  │
      │  Gyokuro                                                green    2m  │
      │  Oolong                                                 oolong   3m  │
      │  Assam                                                  black    4m  │
      │  Darjeeling                                             black    3m  │
      │  Pu-erh                                                 dark     5m  │
      │                                                                      │
      │ Pick a tea.                                                          │
      │ license tea-8f3a91c2d7                                               │
      ╰──────────────────────────────────────────────────────────────────────╯
       ↑/↓ choose  / filter  enter brew  q quit
      reel: wait for /Genmaicha/: context deadline exceeded
ok    tests/shop.tape	710ms
1 passed, 1 failed

The tape's exit code is 3 if any tape failed, so it works in CI as is.

Snapshots

Snapshot NAME compares the screen with testdata/<tape>/NAME.snap. Create or update those with --update:

reel test tests/ --update
git diff tests/testdata

Artifacts

--artifacts DIR writes a .cast and a .gif of each failed tape, for CI to upload:

reel test tests/ --artifacts out/

Open the .cast in the inspector to step through what happened.

.github/workflows/test.yml
- run: reel test tests/ --artifacts out/
- uses: actions/upload-artifact@v7
  if: failure()
  with:
    name: reel-tests
    path: out

When to use steep instead

reel test is good for testing a program as a black box, in any language. steep is for Go programs, when you want to reach the model, wait for messages, or have assertions beyond what a tape can say. A steep exec harness can do what a tape does, with Go's control flow.

Last updated on

On this page