← Recipe: run a delayed action

4. Replace tests/smoke.luau

luastra/timer · app.handle · about 10 minutes
deterministic state-transition test

The test invokes the same timer event that the host delivers and verifies the state read by the following render.

When to use it

Replace the generated smoke test so luastra test verifies application behavior rather than only an isolated UI constructor.

Focused example

--!strict

local app = require("app/main")

local initial = app.snapshot()
assert(initial.elapsed == 0, "timer recipe must start at zero")
assert(initial.value == "waiting", "timer recipe initial value is invalid")

app.handle("timer", "timer/next-card", "next")

local elapsed = app.snapshot()
assert(elapsed.elapsed == 1, "timer event did not advance state")
assert(elapsed.value == "next", "timer event did not preserve its value")

return true

Complete inventory

View all pages in Recipe: run a delayed action
← Previous: 3. Replace src/main.luauNext: 5. Check and run →