Skip to main content

DeathReportTestUtils

Shared harness for the deathreport specs. DeathReportTestUtils.setup boots DeathReportService the way production does -- through a ServiceBag -- and optionally a second, client-realm bag running DeathReportServiceClient against it over dummy-mode remoting. Real players never join a headless place, so players are PlayerMocks created through the server bag's PlayerMockService, and a character is spawned with PlayerMock.loadMinimalCharacterAsync so DeathTrackedHumanoid discovers it like a real join.

Binders are exposed as resolved by the bags (teamKillTrackerBinder, ...): a ServiceBag instantiates its own isolated copy of every service it runs, so the module value a spec requires is never the binder that was started, and binding through it fails.

The test place is shared across a batch run, so every controller derives distinct user ids from a module-level counter and tears down everything it created via Destroy() -- client bag first, then the server bag that owns the mocks.

Functions​

waitFor​

DeathReportTestUtils.waitFor(
condition: () → boolean,
timeout: number?
) → boolean

Polls until the condition passes or the timeout elapses. Returns the final condition result so specs can expect(...).toBe(true) on it.

awaitBound​

DeathReportTestUtils.awaitBound(
binder: Binder<T>,
inst: Instance
) → T

Yields until the binder has bound the instance and returns the bound class.

awaitUnbound​

DeathReportTestUtils.awaitUnbound(
binder: Binder<T>,
inst: Instance
) → ()

Returns once inst is no longer bound. Removal is usually already done by the time we check; the guarded wait also covers a deferred case.

setup​

DeathReportTestUtils.setup(options: {withClient: boolean?}?) → {...}

Builds the controller the specs share.

Fields: maid, serverBag, deathReportService, playerMockService, container, the server binders teamKillTrackerBinder, playerKillTrackerBinder, playerDeathTrackerBinder, and with withClient: clientBag, deathReportServiceClient, playerMockServiceClient and the client binders teamKillTrackerClientBinder, playerKillTrackerClientBinder, playerDeathTrackerClientBinder. Builders: newMock(overrides?) -> Player, newCharacter(mock) -> (Model, Humanoid) bound to DeathTrackedHumanoid, newNpc(name?) -> (Model, Humanoid) untracked, newTeam(name?, brickColor?) -> Team. Actions: setTeam(mock, team?), setLocalPlayer(mock), kill(humanoid, killer?). Lifecycle: destroyClientBag(), destroyServerBag(), Destroy().

Show raw api
{
    "functions": [
        {
            "name": "waitFor",
            "desc": "Polls until the condition passes or the timeout elapses. Returns the final condition result so\nspecs can `expect(...).toBe(true)` on it.",
            "params": [
                {
                    "name": "condition",
                    "desc": "",
                    "lua_type": "() -> boolean"
                },
                {
                    "name": "timeout",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "src/deathreport/src/Shared/DeathReportTestUtils.lua"
            }
        },
        {
            "name": "awaitBound",
            "desc": "Yields until the binder has bound the instance and returns the bound class.",
            "params": [
                {
                    "name": "binder",
                    "desc": "",
                    "lua_type": "Binder<T>"
                },
                {
                    "name": "inst",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 77,
                "path": "src/deathreport/src/Shared/DeathReportTestUtils.lua"
            }
        },
        {
            "name": "awaitUnbound",
            "desc": "Returns once `inst` is no longer bound. Removal is usually already done by the time we check; the\nguarded wait also covers a deferred case.",
            "params": [
                {
                    "name": "binder",
                    "desc": "",
                    "lua_type": "Binder<T>"
                },
                {
                    "name": "inst",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 90,
                "path": "src/deathreport/src/Shared/DeathReportTestUtils.lua"
            }
        },
        {
            "name": "setup",
            "desc": "Builds the controller the specs share.\n\nFields: `maid`, `serverBag`, `deathReportService`, `playerMockService`, `container`, the server\nbinders `teamKillTrackerBinder`, `playerKillTrackerBinder`, `playerDeathTrackerBinder`, and with\n`withClient`: `clientBag`, `deathReportServiceClient`, `playerMockServiceClient` and the client\nbinders `teamKillTrackerClientBinder`, `playerKillTrackerClientBinder`, `playerDeathTrackerClientBinder`.\nBuilders: `newMock(overrides?)` -> Player, `newCharacter(mock)` -> (Model, Humanoid) bound to\n[DeathTrackedHumanoid], `newNpc(name?)` -> (Model, Humanoid) untracked, `newTeam(name?, brickColor?)`\n-> Team.\nActions: `setTeam(mock, team?)`, `setLocalPlayer(mock)`, `kill(humanoid, killer?)`.\nLifecycle: `destroyClientBag()`, `destroyServerBag()`, `Destroy()`.",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "{ withClient: boolean? }?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ... }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 112,
                "path": "src/deathreport/src/Shared/DeathReportTestUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "DeathReportTestUtils",
    "desc": "Shared harness for the deathreport specs. [DeathReportTestUtils.setup] boots [DeathReportService]\nthe way production does -- through a [ServiceBag] -- and optionally a second, client-realm bag\nrunning [DeathReportServiceClient] against it over dummy-mode remoting. Real players never join a\nheadless place, so players are [PlayerMock]s created through the server bag's [PlayerMockService],\nand a character is spawned with [PlayerMock.loadMinimalCharacterAsync] so [DeathTrackedHumanoid]\ndiscovers it like a real join.\n\nBinders are exposed as resolved by the bags (`teamKillTrackerBinder`, ...): a ServiceBag\ninstantiates its own isolated copy of every service it runs, so the module value a spec requires\nis never the binder that was started, and binding through it fails.\n\nThe test place is shared across a batch run, so every controller derives distinct user ids from a\nmodule-level counter and tears down everything it created via `Destroy()` -- client bag first, then\nthe server bag that owns the mocks.",
    "source": {
        "line": 20,
        "path": "src/deathreport/src/Shared/DeathReportTestUtils.lua"
    }
}