Lesson 3 of 6
Integration playtests
Run integration playtests inside a real Roblox Play session. Read Beacon Yard's tests/ harness, invoke RunGameTests, use test-only attributes, keep Output clean, and fix a flaky health check.
By the end you can
- Run Beacon Yard's server and client playtest suites and read every TEST line
- Explain why the suite runs through the RunGameTests bindable and asserts server values, not the HUD
- Shorten a round with test-only attributes without changing the contract numbers in Config
- Replace a flaky equality with the rule you actually mean
Before this: Unit tests with Jest-Lua, Debugging: breakpoints, the console, a method
1Twenty checks in one Play
Press Play, wait for the yard, and run one line from the server command bar:
game.ServerScriptService.RunGameTests:Invoke()
Output fills with lines like TEST PASS coin_pickup and TEST PASS wrench_kill, then TEST SUITE DONE. In about a minute the suite moved your character onto a pad, started a round, stood you next to the drone, swung the wrench three times and bought both shop items. Nothing was mocked.

Select a numbered pin, or a row below, to read what it marks.
The end of a suite run: the last server checks, TEST SUITE DONE, then the client checks.
This is an integration test: it checks that the pieces work together in the real engine. The unit tests of the last lesson check one rule at a time; this suite checks the wiring.
What does coin_pickup check that a unit test of the payout rule cannot?
Answer
That a real Touched event on Pad1, through CoinService and DataService, raises leaderstats.Coins by 5. coin_pickup moves the character, lets the engine fire Touched, and reads the IntValue the server wrote. It fails if any link in that chain breaks.
Open this step in lesson mode · Link to this step · This confused me
2Where the suite lives
Rojo maps the tests/ folder to ReplicatedStorage.GameTests. tests/init.luau returns a function and does nothing until you call it; tests/client.luau is the client half.
local function pass(name: string)
print("TEST PASS " .. name)
end
local function fail(name: string, reason: string)
print("TEST FAIL " .. name .. ": " .. reason)
end
local function skip(name: string, reason: string)
print("TEST SKIP " .. name .. ": " .. reason)
end
local function expect(name: string, ok: boolean, reason: string)
if ok then
pass(name)
else
fail(name, reason)
end
end
local function waitFor(seconds: number, predicate: () -> boolean): boolean
Every check goes through expect(name, ok, reason). A pass prints the name; a failure prints the name and a reason with the real numbers, such as coins 0 -> 3, wanted +5. A good failure message is half the debugging done.
Which failure reason helps most when coin_pickup fails?
Answer
coins 120 -> 120, wanted +5. The first says the balance did not move at all, which points at the touch or the distance check, not at the amount. The others only say that something broke.
Open this step in lesson mode · Link to this step · This confused me
3Why a bindable, not require
The previous lessons met the command bar trap: it has its own require cache, so a test required from it would get a second, empty DataService. The server script avoids this by requiring the suite itself and exposing a BindableFunction1.
local testModule = ReplicatedStorage:FindFirstChild("GameTests")
if testModule and testModule:IsA("ModuleScript") then
local runTests = require(testModule) :: () -> ()
local runner = Instance.new("BindableFunction")
runner.Name = "RunGameTests"
runner.Parent = ServerScriptService
function runner.OnInvoke(): string
runTests()
return "ran"
Invoking the bindable runs the suite inside the live server's cache, with the real profiles. The client half has no such problem, because it only reads the HUD and input bindings, so you run it with a plain require in the client command bar.
A full run: Play, the bindable, the server lines, then the client module.
Transcript
- 0:00 Play is running and the yard has been built.
- 0:07 RunGameTests uses the server script's require cache.
- 0:26 The pass lines include the coin, the shop, the drone, and the shield.
- 0:29 The client module then prints TEST CLIENT DONE.
Build along
tests/init.luautests/client.luausrc/server/init.server.luau
Check out
m06-drone-wrench, runrojo serve, connect Studio and press Play.You should see Workspace.Yard exists in Explorer and your character stands in the yard.
Switch the command bar to the server and run
game.ServerScriptService.RunGameTests:Invoke().You should see TEST PASS lines arrive over about a minute and end with TEST SUITE DONE. DataStore checks print TEST SKIP in an unpublished place.
Switch the command bar to the client and run
require(game.ReplicatedStorage.GameTests.client)().You should see TEST PASS ui_scale, hud_coins, hud_objective and swing_action, then TEST CLIENT DONE.
Press Stop before the next run, so coins and the phase start fresh.
You should see Studio returns to edit mode. Workspace.Yard is gone, because MapBuilder builds it only in Play.
Open this step in lesson mode · Link to this step · This confused me
4Assert the scoreboard, not the broadcast
The server suite never looks at the HUD. It reads the leaderstats.Coins IntValue the server wrote, the RoundPhase attribute the server set, and the drone's health on the server.
What the client shows is the broadcast. A test that reads the HUD is checking the TV picture. A test that reads the server's IntValue is checking the scoreboard the broadcast was made from.
Think of it as The live broadcast
Both sidesRemember: Replication is the live broadcast.
The client suite does read the HUD, on purpose: it checks that the broadcast was drawn correctly. Two suites, two sides, two questions.
Match each check to the suite and side that should own it.
Answer
Buying Speed spends 25 coins: Server suite, reading the profile and leaderstats; The coins label shows the right number: Client suite, reading the HUD; The wrench is bound to F and ButtonR2: Client suite, reading ContextActionService; Three swings take the drone from 100 to 0: Server suite, reading the drone's health. Coins, purchases and damage are server facts. Labels and input bindings exist only on the client, so the client suite checks them.
Open this step in lesson mode · Link to this step · This confused me
5Shorter rounds without lying in Config
A real round lasts 40 seconds and the cooldown 8. The suite cannot wait that long for every run, but it must not change Config.luau either, because config_numbers checks those numbers as a contract.
So the game reads three workspace attributes that only the suite sets: TestRoundSeconds, TestCooldownSeconds and TestCoinRespawnSeconds. The suite sets them, waits, and clears them. The game never sets them.
-- Tests shorten the phases with workspace attributes. The game never
-- sets them, so Play uses the Config numbers.
local function positiveOverride(name: string): number?
local override = workspace:GetAttribute(name)
if typeof(override) == "number" and override > 0 then
return override
end
return nil
end
local function publish(phase: RoundPhase, endsAt: number)
The suite sets TestRoundSeconds to 14. How many seconds does Config.ROUND_SECONDS still say?
Answer
40 seconds. Config stays at 40. positiveOverride returns 14 only while the attribute is set, and config_numbers keeps checking 40.
Open this step in lesson mode · Link to this step · This confused me
6Output must stay clean
no_output_errors watches Output from the start of the test round until the phase is Idle again. Any error fails it. A warning fails it too, unless its text contains one of five needles, and every needle has a row in tests/README.md explaining why.
local function warningAllowed(message: string): boolean
-- Each needle is justified in tests/README.md. Do not add one here
-- without a row in that file.
local allowed = {
"[Ids]",
"DataStore unavailable",
"DataStore load failed",
"DataStore session",
"Asset type does not match",
}
for _, needle in allowed do
if string.find(message, needle, 1, true) then
return true
end
end
return false
This is why the debugging lesson said to delete trace prints and keep warn for real failures. A new warn("picked up a coin") would fail the suite.
During the server suite, your new ShopService debug line emits warn("Shop opened"). What happens?
Answer
no_output_errors fails, because the text matches none of the allowed needles. Only warnings containing [Ids], DataStore unavailable, DataStore load failed, DataStore session or Asset type does not match pass. Anything else is a failure, by design.
Open this step in lesson mode · Link to this step · This confused me
7A flaky check, and the rule you meant
shield_absorb buys a shield, stands you next to the drone and checks that the hit was absorbed. The first version compared health with ==. It passed at full health and failed at random below it.
The reason: the default character Health script heals about 1 point a second while you are under 100. During the wait, 85 can become 86. Equality fails; nothing is wrong with the shield. A test that passes or fails on the same code is called Flaky testFlaky testA test that passes or fails on the same code, depending on timing or chance.Think of it as a smoke alarm that sometimes goes off when you make toast..
-- The default character Health script heals about 1 per second, so
-- "no hit" means health did not drop by a drone strike.
local held = afterAbsorb ~= nil and afterAbsorb.Health > healthBefore - 5
The fix is to write the rule you mean: "health did not drop by a drone strike". A strike is 15, so anything above before - 5 holds.
local function equalRule(before, after)
return after == before
end
local function yardRule(before, after)
return after> before - 5
end
for _, case in { {85, 85}, {85, 86}, {85, 70}, {100, 100} } do
local before, after = case[1], case[2]
print(before .. " -> " .. after .. ": equal " .. tostring(equalRule(before, after)) .. ", yard " .. tostring(yardRule(before, after)))
end
85 -> 85: equal true, yard true
85 -> 86: equal false, yard true
85 -> 70: equal false, yard false
100 -> 100: equal true, yard trueHealth is 90 before the shield check and 85 after. What does the suite's rule (after > before - 5) return?
local before, after = 90, 85
print(after > before - 5)
Answer
false. 85 is not greater than 85, so a drop of exactly 5 fails. The boundary is strict on purpose: a real strike is 15.
Open this step in lesson mode · Link to this step · This confused me
8From the suite to the Course Runner
Challenges in this course are graded the same way: a learner file you edit, and a test module that prints TEST PASS lines.
game.ServerScriptService.RunGameTests:Invoke() runs the full server suite. To grade just this challenge, use m14-ship, press Play and run game.ServerScriptService.RunGameTests:Invoke("automated-tests") in the server command bar. The first argument is the test module name. If the challenge ID differs from that name, give the ID as the second argument. When all checks pass, copy the BY- code from the PASS CODE: line in Output. Calling a challenge module directly bypasses the runner and does not print that code.
Other ways pros do this
| Option | What it is | When pros pick it | Trade-offs |
|---|---|---|---|
| Playtest harness in Studio | A suite that runs inside Play and prints TEST lines, like tests/. | Integration checks of real gameplay: touches, rounds, purchases. | Slow, needs Studio, and timing can make it flaky. |
| StudioTestService | Studio-only service to start a server with up to 8 simulated clients from a plugin or pipeline. | Multiplayer and join-leave tests driven by tooling. | Studio only; does nothing in a published game. |
| Open Cloud Luau Execution | Runs a script headlessly on a Roblox server against a published place version. | CI: every pull request, no Studio on the runner. | No real player character, 5-minute task limit, needs an API key and a test place. |
| Studio MCP | An MCP server that lets an assistant start Play, run Luau and read Output. | Driving the playtest suite from a script or an AI agent on your machine. | Still runs your local Studio, so it is not a CI runner. |
On a checkout with the Course Runner, what is the difference between RunGameTests:Invoke() and RunGameTests:Invoke("automated-tests")?
Answer
No argument runs the full server playtest suite; passing "automated-tests" runs the seven challenge checks and prints a BY- pass code when all pass. RunGameTests:Invoke() runs the full server suite. Passing a test name runs that challenge and prints a PASS CODE: BY-... line when every check passes.
Open this step in lesson mode · Link to this step · This confused me
9Where the broadcast picture breaks
Where does it break?“The live broadcast” is a good picture of replication. Where does it stop being true?
It breaks here. Only property changes in some containers are sent, and nothing a client changes ever travels back up to the server.
The true model. The server copies changes in replicated containers, such as Workspace and ReplicatedStorage, down to clients. A client's own changes stay on that client unless it asks the server through a remote.
The broadcast picture says the client only receives. That is mostly true for game state, and it is why the server suite cannot see the HUD. But the client also produces things the server never sees: its own GUI, its input bindings, its camera. A suite that runs only on the server has a blind spot exactly there, which is why tests/client.luau exists.
Which of these can only be checked from the client?
Answer
That WrenchSwing is bound to F, ButtonR2 and a touch button. Input bindings are made by the client's CombatClient and exist only there. The other three are server facts the server suite reads.
Open this step in lesson mode · Link to this step · This confused me
10Challenges
Level 1, Apprentice
Challenge
Run both suites and account for every line that is not a pass.
- Start from
- The game at milestone m06 (download)
Done means
- You run the server and client suites in one Play session
- You list which checks printed TEST SKIP and why
Hints
- Use the BuildAlong above.
- In an unpublished place, GetDataStore throws, so the store checks skip.
Why does datastore_roundtrip print TEST SKIP in a fresh, unpublished place?
Answer
GetDataStore throws there, so the check has nothing real to test. DataStores need a published place with Studio API access. A skip says the check could not run here; it is neither a pass nor a fail.
Level 2, Builder
Challenge
Add one integration check to tests/init.luau for the gates.
- Start from
- The game at milestone m06 (download)
Done means
- A new check, gate_open, asserts the left gate moves away from its closed position during Active
- It reads the server's part position, not a client view
- The suite still ends with TEST SUITE DONE and every old check passes
Hints
- RoundService tweens the gates 9 studs on X when the drill starts.
- Workspace.Yard holds the gates; read the CFrame before requestStart and after round_active.
- Allow for the 1 second tween before you compare.
Level 3, Professional
Challenge
Replace the flaky equality in the learner file with the suite's rule. To grade the change, use m14-ship, press Play and run this in the server command bar:
game.ServerScriptService.RunGameTests:Invoke("automated-tests")
- Start from
- The game at milestone m06 (download)
- Grade it
- To grade work from an earlier milestone, apply your challenge changes to a checkout based on
m14-ship, which includes the Course Runner. In Studio, press Play, then rungame.ServerScriptService.RunGameTests:Invoke("automated-tests")in the server command bar. Copy the pass code from Output.
Done means
- challenges/automated_tests_work.luau implements health > before - 5
- A heal of 1 or 2 holds, a drop of 15 fails, a drop of exactly 5 fails
- challenges/automated-tests.luau prints TEST PASS for all seven cases
Hints
- The comment above the shield check in tests/init.luau says why equality flakes.
- Write the rule you mean: no drone strike.
Solution
function Work.shieldHeld(beforeHealth: number, afterHealth: number): boolean
return afterHealth > beforeHealth - 5
end
Open this step in lesson mode · Link to this step · This confused me
11Recap
Recap
- Playtests run the real game: invoke RunGameTests on the server, then require the client half on the client.
- Assert server values for server facts, keep contract numbers in Config, and shorten sessions with test-only attributes.
- Fix flaky checks by writing the rule you mean, and keep Output clean so warnings stay meaningful.
Replication is the live broadcast, until only property changes in some containers are sent, and nothing a client changes ever travels back up to the server.
Queued for review
- What does coin_pickup check that a unit test of the payout rule cannot?
- Match each check to the suite and side that should own it.
- During the server suite, your new ShopService debug line emits warn("Shop opened"). What happens?
- Health is 90 before the shield check and 85 after. What does the suite's rule (after > before - 5) return?
- Which of these can only be checked from the client?
Open this step in lesson mode · Link to this step · This confused me