← Recipe: replay declarative motion

4. Replace tests/smoke.luau

luastra/motion · stable UI identity · about 15 minutes
descriptor contract + one state transition

The test verifies the initial descriptors, drives the real button action, and proves the changed direction with the same node ID.

When to use it

Replace the generated smoke test so luastra test checks application intent and the public motion descriptors without simulating private scheduler frames.

Focused example

--!strict

local app = require("app/main")

local function find(node: any, id: string): any?
    if node.id == id then return node end
    for _, child in node.children or {} do
        local result = find(child, id)
        if result ~= nil then return result end
    end
    return nil
end

local initialCard = find(app.render(), "motion/card") :: any
local initialMotion = initialCard.properties.motion :: any
local initialOpacity = initialMotion.opacity :: any
local initialTranslation = initialMotion.translateX :: any
assert(initialCard.id == "motion/card")
assert(initialOpacity.kind == "tween")
assert(initialOpacity.from == 0 and initialOpacity.to == 1)
assert(initialTranslation.from == -28)
assert(initialTranslation.to == 0)

app.handle("motion.replay", "motion/replay", "")
local snapshot = app.snapshot()
assert(snapshot.run == 1 and snapshot.fromLeft == false)

local changedCard = find(app.render(), "motion/card") :: any
local changedMotion = changedCard.properties.motion :: any
local changedTranslation = changedMotion.translateX :: any
assert(changedCard.id == initialCard.id)
assert(changedTranslation.from == 28)
assert(changedTranslation.to == 0)

return true

Complete inventory

View all pages in Recipe: replay declarative motion
← Previous: 3. Replace src/main.luauNext: 5. Check and run →