Skip to content

Test data, setup and teardown

A test is only repeatable if it starts from the same place every time. Most of the time that means data: the user exists, the cart is empty, the document from last time is gone.

name: Exporting a report creates a PDF
app: web
setup:
- run: npm run db:reset # before the steps
steps:
- click: button "Export"
- expect: { file: ./out/report.pdf, contains: Total }
teardown:
- run: rm -f ./out/report.pdf # after the steps, even if they failed

teardown always runs, pass or fail, so cleanup happens even when the test breaks halfway.

For setup that every test of an app needs, put it on the app in sisyphus.yaml (setup: and teardown: under the app). A test opts out with app_setup: false.

run: executes a command in your project folder, using your shell:

- run: npm run db:seed
- run:
script: scripts/seed.sh # interpreter picked from the extension
args: [--user, "${email}", --count, 3]
env: { API_URL: "${base}" }
code: [0, 3] # exit codes that count as success
- run:
script: scripts/seed.sh
windows: { script: scripts/seed.ps1 } # a different one on Windows

Scripts can be shell, PowerShell, Python, Node, Ruby or any executable. Inline commands run in sh, or cmd on Windows; set defaults: { shell: sh } in sisyphus.yaml to write them once for every OS (Windows then uses Git Bash). After the step, ${output} holds what it printed and ${exit_code} its exit code. A failing command fails the step with COMMAND_FAILED and the end of its error output. Commands are stopped after 2 minutes unless you set timeout:.

Prefer creating data directly (a script, an API call, a database seed) when the creation itself isn’t what’s being tested. It’s faster and fails for fewer reasons. Create it through the UI when that’s the behaviour under test.

When tests run at the same time (--workers 4), two tests must not change the same record. Give each its own:

vars:
email: user${worker}@example.com # user0@, user1@, … one per worker

or make it unique with ${random}.

If the app needs a server running, let Sisyphus start it:

sisyphus.yaml
apps:
web:
url: http://localhost:3000
serve: { command: npm run dev, ready: http://localhost:3000 }

It starts once per run, waits until ready answers, and stops at the end.

Made by Bussin Bytes© 2026 Bussin Bytes Ltd · sisyphus.bussinbytes.io