Skip to main content

BinderTestUtils

Shared harness for the Binder specs. BinderTestUtils.setup boots binders the way production code boots them: registered on a BinderProvider that is Init/Start'd through a ServiceBag and torn down through serviceBag:Destroy(). Adornees are parented into a workspace container because CollectionService.GetInstanceAddedSignal only fires for instances that live in the DataModel.

Tags are global and the test place is shared across a batch run, so every binder gets a distinct tag from a single module-level counter -- shared across every spec file that requires this module, so tags never collide between files -- and each controller cleans up after itself via destroy().

Functions

makeTrackingClass

BinderTestUtils.makeTrackingClass() → TrackingClass

A minimal bound class that records its instance and whether it was destroyed. It deliberately does NOT retain its constructor varargs: the ServiceBag is injected as a constructor arg, and its object graph contains Quenty Signals whose strict __index makes jest's deep-equality traversal throw. Keeping the class free of them lets toEqual compare instances safely.

awaitUnbound

BinderTestUtils.awaitUnbound(
binderBinder,
instInstance
) → ()

Returns once inst is no longer bound. CollectionService tag removal is synchronous here, so the class is usually already gone by the time we check; the guarded wait also covers a deferred case.

noopConstructor

BinderTestUtils.noopConstructor() → table

A no-op constructor that still returns a value, so Binder's generic bound type stays inhabited.

setup

BinderTestUtils.setup() → {...}

Builds the controller the Binder specs share. Register binders with addBinder, boot them all at once through a ServiceBag with boot, create adornees with newInstance, and tear everything down with destroy (or just the service bag with destroyServiceBag).

Fields: container. Builders: addBinder(constructor, ...) -> Binder, newInstance(parent?, className?) -> Instance. Lifecycle: boot(), destroyServiceBag(), destroy(). Helpers: uniqueTag() -> string.

Show raw api
{
    "functions": [
        {
            "name": "makeTrackingClass",
            "desc": "A minimal bound class that records its instance and whether it was destroyed. It deliberately does\nNOT retain its constructor varargs: the ServiceBag is injected as a constructor arg, and its object\ngraph contains Quenty Signals whose strict __index makes jest's deep-equality traversal throw.\nKeeping the class free of them lets toEqual compare instances safely.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TrackingClass"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 33,
                "path": "src/binder/src/Shared/BinderTestUtils.lua"
            }
        },
        {
            "name": "awaitUnbound",
            "desc": "Returns once `inst` is no longer bound. CollectionService tag removal is synchronous here, so the\nclass is usually already gone by the time we check; the guarded wait also covers a deferred case.",
            "params": [
                {
                    "name": "binder",
                    "desc": "",
                    "lua_type": "Binder"
                },
                {
                    "name": "inst",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "src/binder/src/Shared/BinderTestUtils.lua"
            }
        },
        {
            "name": "noopConstructor",
            "desc": "A no-op constructor that still returns a value, so Binder's generic bound type stays inhabited.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 70,
                "path": "src/binder/src/Shared/BinderTestUtils.lua"
            }
        },
        {
            "name": "setup",
            "desc": "Builds the controller the Binder specs share. Register binders with `addBinder`, boot them all at\nonce through a ServiceBag with `boot`, create adornees with `newInstance`, and tear everything down\nwith `destroy` (or just the service bag with `destroyServiceBag`).\n\nFields: `container`.\nBuilders: `addBinder(constructor, ...)` -> Binder, `newInstance(parent?, className?)` -> Instance.\nLifecycle: `boot()`, `destroyServiceBag()`, `destroy()`.\nHelpers: `uniqueTag()` -> string.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ... }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 86,
                "path": "src/binder/src/Shared/BinderTestUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "BinderTestUtils",
    "desc": "Shared harness for the Binder specs. [BinderTestUtils.setup] boots binders the way production code\nboots them: registered on a [BinderProvider] that is Init/Start'd through a [ServiceBag] and torn\ndown through `serviceBag:Destroy()`. Adornees are parented into a workspace container because\nCollectionService.GetInstanceAddedSignal only fires for instances that live in the DataModel.\n\nTags are global and the test place is shared across a batch run, so every binder gets a distinct\ntag from a single module-level counter -- shared across every spec file that requires this module,\nso tags never collide between files -- and each controller cleans up after itself via `destroy()`.",
    "source": {
        "line": 14,
        "path": "src/binder/src/Shared/BinderTestUtils.lua"
    }
}