4. Replace tests/smoke.luau
luastra/ui · app.render · app.handle · about 15 minutesdeterministic interaction test
The test imports the real entry module, exercises the same actions emitted by the buttons, and proves that an unrelated target cannot mutate state.
When to use it
Replace the generated smoke test so luastra test verifies this application's behavior instead of only constructing an unrelated SDK node.
- The test calls handle directly, so it is deterministic and does not need a browser.
- The live preview separately proves pointer, keyboard, DOM, and visible status behavior in the current host.
- When you add a new product rule, add its state transition here before relying on manual testing alone.
Focused example
--!strict
local app = require("app/main")
assert(app.snapshot().count == 0, "counter must start at zero")
local initialTree = app.render()
assert(initialTree.type == "Screen", "render must return one Screen root")
assert(initialTree.id == "counter", "screen id must remain stable")
app.handle("counter.add", "counter/add", "")
assert(app.snapshot().count == 1, "Add one must increment the count")
app.handle("counter.add", "another/control", "")
assert(app.snapshot().count == 1, "an unrelated target must not change state")
app.handle("counter.reset", "counter/reset", "")
assert(app.snapshot().count == 0, "Reset must restore zero")
return true