Forest Logo
search
package_2

checkpoint

By @jannik-ritter

Roblox

Mirrored from Wally

Checkpoint

End-to-end tests for Rojo-synced Luau games. Scenarios are Luau modules that run inside a real Roblox Studio playtest; a Lune CLI drives Studio over the Studio MCP, reports each step, sends real mouse and keyboard input when a scenario asks for it, and saves a screenshot and the console log when a step fails.

$ lune run checkpoint run
running 2 scenario(s) in MyGame
game ready

core/boot  Server and client finish loading, and no module fails to require.
  ✓ server loaded (server, 4ms)
  ✓ client loaded (client, 9ms)

shop/buy  Buying an item spends coins once.
  ✓ open shop (client, 120ms)
  ✗ coins spent (server, 10003ms)
      expected coins to be 50 within 10s, last 100
      .checkpoint/shop-buy--coins-spent.jpg
      .checkpoint/shop-buy--coins-spent.log

1 passed, 1 failed

One Wally package holds both halves: the in-game harness (src/) and the Lune runner (runner/). They always come from the same version.

Setup

Requirements: Rokit with Wally, Rojo and Lune, and Roblox Studio with its MCP server enabled. On Windows and from WSL the runner starts Studio's MCP (%LOCALAPPDATA%\Roblox\mcp.bat) through cmd.exe; elsewhere, or for another MCP, pass its command with --mcp or CHECKPOINT_MCP.

  1. Add the package as a dev dependency and install it:

    # wally.toml
    [dev-dependencies]
    checkpoint = "jannik-ritter/checkpoint@0.2.0"
    
    rokit add lune-org/lune
    wally install
    

    Dev dependencies install into DevPackages/, apart from the game's Packages/.

  2. Copy the templates from DevPackages/_Index/jannik-ritter_checkpoint@<version>/checkpoint/templates/ into the project root:

    • .lune/checkpoint.luau: the shim behind lune run checkpoint. It finds the installed version, so it never needs editing.
    • tests/adapter.luau and tests/core/boot.luau: a starting adapter and scenario.
  3. For type checking, map DevPackages in default.project.json so luau-lsp can follow Wally's link files. This syncs the package into the place's ServerStorage, where clients never see it and nothing runs:

    "ServerStorage": {
    	"DevPackages": { "$path": { "optional": "DevPackages" } }
    }
    

    optional keeps Rojo working when dev dependencies aren't installed.

  4. Optionally copy skill/ to .agents/skills/checkpoint/ so coding agents know how to write and run scenarios.

Running

Open the game in Studio, sync it with rojo serve, and stay in Edit mode. Then:

lune run checkpoint list                    # scenarios, grouped by domain
lune run checkpoint run                     # every scenario
lune run checkpoint run shop                # a domain, a path (shop/buy) or a name (buy)
lune run checkpoint run lobby/b lobby/a     # in the order given
lune run checkpoint run --json              # one JSON event per line, for agents and CI
Option
--studio <name>Pick a Studio when several are connected (or CHECKPOINT_STUDIO).
--retries <n>Run a failed scenario again up to n times. One that passes on a retry is reported as flaky.
--bailStop at the first failed scenario.
--failedRun the scenarios that failed last time (.checkpoint/last-run.json).
--isolateA fresh playtest for each scenario, instead of one for the run.
--shuffle, --seed <n>A random order, to find scenarios that depend on each other. The seed is printed; --seed repeats an order.
--no-sync-check, --rojo <url>See "Sync check" below.
--mcp <command>The Studio MCP command (or CHECKPOINT_MCP).
--timeout <seconds>Give up on the whole run after this long (default 600).

Exit codes: 0 all passed (flaky ones included), 1 a scenario failed, 2 the run could not complete (no Studio, another run in progress, a stale sync, a timeout). Failure screenshots, console logs, ctx.screenshot images and last-run.json go to .checkpoint/; add it to .gitignore.

How a run works

  1. The runner checks that Studio holds the scripts Rojo serves (the sync check).
  2. It starts a playtest with StudioTestService:ExecutePlayModeAsync, whose test args carry the run's config under checkpoint.
  3. Into the running server it injects the selected scenarios, the adapter, the helper folders and the dev packages the tests use at ReplicatedStorage.Checkpoint, mirroring the project layout, plus a server Script and a client harness the server puts in the player's PlayerGui. Nothing is added to the Edit place, so a crash, an autosave or a killed run can't leave the harness behind or get it published.
  4. The server waits for the test player and the adapter's ready hook on both sides, then runs the scenarios in order and writes progress events to ServerStorage.CheckpointStatus. The runner reads the new ones four times a second and answers the harness's requests (input, screenshots, the capture of a failed step).
  5. When the run is done the harness ends the playtest itself with StudioTestService:EndTest. If the runner stops polling for 30 s (killed, crashed), the harness ends the playtest too, so Studio always returns to Edit.

A run that finds Studio in a playtest refuses to start unless it is a Checkpoint playtest whose runner has stopped polling, which it then stops. A Checkpoint playtest another runner is still polling is never touched: one run per Studio at a time.

Game code under test

Game code tells it is under test from the test args, which are there before any script runs:

local function isTestRun(): boolean
	if not RunService:IsStudio() then
		return false
	end
	local args = StudioTestService:GetTestArgs() :: any
	return type(args) == "table" and args.checkpoint ~= nil
end

Use it for what must be decided at start-up, such as mock persistence. Everything else belongs in the adapter's reset. A normal Play never has these args, so it never runs as a test.

Sync check

Before each run the runner reads every script from the Rojo serve (http://127.0.0.1:34872, or --rojo <url> / CHECKPOINT_ROJO) and compares its length and hash with Studio's. If any differ (a serve that died, a disconnected Rojo plugin), the run stops and lists them, instead of testing stale code. When no serve answers, or it serves a model rather than a place, the check is skipped with a note. --no-sync-check turns it off.

Writing tests

tests/
	adapter.luau             hooks: ready, reset
	<domain>/<name>.luau     one scenario per module
	_<anything>/             helper modules (not scenarios)

Adapter

local Checkpoint = require("../DevPackages/checkpoint")

return Checkpoint.adapter({
	-- Polled on the server and the client until both return true.
	ready = function(side)
		return workspace:GetAttribute(if side == "server" then "ServerLoaded" else "ClientLoaded") == true
	end,

	-- Runs on the server before every scenario: restore a neutral state and apply the scenario's fixture.
	reset = function(player, fixture) end,
})

Scenarios

--!strict
local Checkpoint = require("../../DevPackages/checkpoint")
local PlayerData = require("@game/ReplicatedStorage/Modules/Shared/PlayerData")
local RewardData = require("@game/ReplicatedStorage/Modules/Data/RewardData")

local t = Checkpoint.t

return Checkpoint.scenario({
	description = "Claiming the daily reward grants coins once.",
	fixture = { Coins = 0 },
	steps = {
		Checkpoint.client("claim", function(ctx)
			local button = ctx.player.PlayerGui:WaitForChild("Daily"):WaitForChild("Claim")
			ctx.click(button) -- a real click, as a player would
		end),
		Checkpoint.server("coins granted once", function(ctx)
			ctx.poll(function()
				return PlayerData.Server.Get(ctx.player).Coins.Get()
			end, "coins"):toBe(100)
			ctx.holds(function()
				return PlayerData.Server.Get(ctx.player).Coins.Get()
			end, "coins", 2):toBe(100) -- and not granted again
			ctx.expect(RewardData.Daily, "daily reward"):toMatch(t.interface({ Coins = t.numberPositive }))
		end),
	},
})
  • The relative require resolves on disk (luau-lsp) and in Studio (the injected tree mirrors the project), so scenarios are type-checked against Checkpoint and the game.
  • A scenario module loads on both sides. Require side-specific game modules inside the step that uses them.
  • Steps run in order on their side. After a failure the remaining steps are skipped. Each step times out after 30s; pass a third argument to change it. Long steps are fine: the harness reports a heartbeat while they run.
  • There is no sleep: wait for an observable condition with poll, waitFor or waitForSignal, check that something stays true with holds, and wait a frame with nextFrame.

The step context (ctx)

Named ctx by convention so t stays free for the type checker.

player, sideThe test player and the side this step runs on.
stateA table shared by the scenario's steps on both sides; it travels with each client step and comes back. Keep to values a RemoteFunction can carry.
expect(value, label?)Checks a value once.
poll(read, label?, timeout?)Retries read until the matcher passes (10s by default).
holds(read, label?, duration?)Samples read for duration (1s by default) and fails as soon as the matcher doesn't pass: "stays closed", "is never granted twice".
waitFor(read, label?, timeout?)Returns the first truthy value read produces.
waitForSignal(signal, label?, timeout?, predicate?)Waits for the signal (with arguments predicate accepts) and returns its arguments.
nextFrame(count?)Waits frames.
click(target, button?)Client steps. Clicks a GuiObject through Studio's input, the way a player would; it must be visible and on screen (the step waits up to 5 s for it, then fails saying why). Or a Vector2 in AbsolutePosition space.
press(key, hold?), keyDown(key), keyUp(key), type(text)Client steps. Real keyboard input (an Enum.KeyCode or its name).
screenshot(name)Saves a screenshot of the playtest to .checkpoint/ and returns its path.
log(...)Prints under the step in the report (an event in --json): measurements, what a step saw.
afterStep(fn)Runs at the end of this step, pass or fail.
onCleanup(fn)Runs at the end of the scenario, pass or fail, on the side that registered it.

Matchers: toBe, toEqual, toBeTruthy, toBeFalsy, toBeNil, toBeGreaterThan, toBeLessThan, toBeAtLeast, toBeAtMost, toBeCloseTo(expected, tolerance?) (numbers, Vector2, Vector3, CFrame positions), toContain, and toMatch(check) for any t check (Checkpoint.t). Every matcher has a negated form: ctx.expect(window).never:toBe("Shop").

  • Scenarios and the adapter are validated when they load, so a malformed one fails with a message instead of mid-run. An adapter that fails to load on the client says so.
  • Keep scenarios independent: use fixture and the adapter's reset, and onCleanup for anything else a scenario changes. --shuffle finds the ones that aren't; --isolate gives each its own playtest.

Limits

  • Real input goes through the Studio window: a click lands on whatever is drawn at that point, and the strip under Roblox's top bar takes no clicks.
  • One player per run.
  • A step that times out is cancelled, but threads it spawned keep running.
  • Runs need a running Studio, so they cannot run on hosted CI.

Development

See AGENTS.md. scripts/install-local.sh <project> installs the working copy into a game's DevPackages to try changes before publishing.

License

MIT

Package Details

Install command (Click to copy)


Version

0.2.0

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.