← Recipe: call a server function

7. Replace tests/smoke.luau

generated Luau client · trusted JavaScript handler · about 25 minutes
generated decoder + controlled UI

The smoke test proves the offline contracts without pretending that its isolated VM owns a live backend.

When to use it

Replace the smoke test so checkable decoder and UI behavior stay deterministic without introducing a fake network response.

Focused example

--!strict

local app = require("app/main")
local ServerFunctions = require("app/server-functions")

local decoded = ServerFunctions.decodeGreet("v=1&result.message=Hello%2C%20Ada%21")
assert(decoded ~= nil and decoded.message == "Hello, Ada!")
assert(ServerFunctions.decodeGreet("v=1") == nil)
assert(ServerFunctions.decodeGreet("v=1&result.message=Hello&extra=value") == nil)

local initial = app.snapshot()
assert(initial.name == "Ada" and initial.status == "Ready" and not initial.busy)
app.handle("greeting.name", "greeting/name", "Grace")
local changed = app.snapshot()
assert(changed.name == "Grace" and changed.status == "Ready")
assert(app.render().type == "Screen")

return true

Complete inventory

View all pages in Recipe: call a server function
← Previous: 6. Replace src/main.luauNext: 8. Check and run →