Skip to main content

PlayerMockUtils

Mock identity: recognizing one, and finding the ones in the DataModel. Tag resolution is DataModel-scoped, so a mock is discoverable the moment it is parented in.

Every other helper guards its arguments with PlayerMockUtils.isMock, so this module stays a leaf -- discovery keyed by a value only another helper can read lives with that helper instead (see PlayerMockPlayerServiceUtils.getPlayerByUserId and PlayerMockCharacterUtils.getMockFromCharacter).

Functions

isMock

PlayerMockUtils.isMock(valueany) → boolean

Requiring the backing Folder rejects a foreign instance merely carrying the tag.

Use PlayerMock.isMock.

findFirstAncestorMock

PlayerMockUtils.findFirstAncestorMock(instanceInstance) → Player?

Like the engine call it walks from the parent, so instance itself is never returned.

Use PlayerMock.findFirstAncestorMock.

getMocks

PlayerMockUtils.getMocks() → {Player}

Returns the mocks currently in the DataModel.

Use PlayerMock.getMocks.

getMockAddedSignal

PlayerMockUtils.getMockAddedSignal() → RBXScriptSignal

The PlayerMockUtils.isMock guard is applied before the signal fires, so it only ever hands back a genuine mock.

Use PlayerMock.getMockAddedSignal.

getMockRemovingSignal

PlayerMockUtils.getMockRemovingSignal() → RBXScriptSignal

Fires whether the mock was destroyed or merely unparented.

Use PlayerMock.getMockRemovingSignal.

getMockedLocalPlayer

PlayerMockUtils.getMockedLocalPlayer() → Player?

Returns the mock designated as the local player, or nil.

Use PlayerMock.getMockedLocalPlayer.

observeMockedLocalPlayer

PlayerMockUtils.observeMockedLocalPlayer() → Observable<Player?>

Observes the mock designated as the local player (see PlayerMock.setMockedLocalPlayer), emitting the current designation on subscribe and again whenever it changes. This replaces one-shot reading PlayerMock.getMockedLocalPlayer, which goes stale when a test designates after the consumer initializes (designation is only required before bags Start, not before Init). Like the getter, this only ever emits the mock -- the real Players.LocalPlayer fallback stays an explicit read at the call site.

Re-designating from one mock to another emits nil in between: the designation is carried as a CollectionService tag on the mock, and the switch removes the old tag before adding the new one.

Show raw api
{
    "functions": [
        {
            "name": "isMock",
            "desc": "Requiring the backing Folder rejects a foreign instance merely carrying the tag.\n\nUse [PlayerMock.isMock].",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 36,
                "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
            }
        },
        {
            "name": "findFirstAncestorMock",
            "desc": "Like the engine call it walks from the parent, so `instance` itself is never returned.\n\nUse [PlayerMock.findFirstAncestorMock].",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Player?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 50,
                "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
            }
        },
        {
            "name": "getMocks",
            "desc": "Returns the mocks currently in the DataModel.\n\nUse [PlayerMock.getMocks].",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ Player }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 71,
                "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
            }
        },
        {
            "name": "getMockAddedSignal",
            "desc": "The [PlayerMockUtils.isMock] guard is applied before the signal fires, so it only ever hands back\na genuine mock.\n\nUse [PlayerMock.getMockAddedSignal].",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RBXScriptSignal"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 90,
                "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
            }
        },
        {
            "name": "getMockRemovingSignal",
            "desc": "Fires whether the mock was destroyed or merely unparented.\n\nUse [PlayerMock.getMockRemovingSignal].",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RBXScriptSignal"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 113,
                "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
            }
        },
        {
            "name": "getMockedLocalPlayer",
            "desc": "Returns the mock designated as the local player, or nil.\n\nUse [PlayerMock.getMockedLocalPlayer].",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Player?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 136,
                "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
            }
        },
        {
            "name": "observeMockedLocalPlayer",
            "desc": "Observes the mock designated as the local player (see [PlayerMock.setMockedLocalPlayer]), emitting\nthe current designation on subscribe and again whenever it changes. This replaces one-shot reading\n[PlayerMock.getMockedLocalPlayer], which goes stale when a test designates after the consumer\ninitializes (designation is only required before bags Start, not before Init). Like the getter,\nthis only ever emits the mock -- the real `Players.LocalPlayer` fallback stays an explicit read at\nthe call site.\n\nRe-designating from one mock to another emits nil in between: the designation is carried as a\nCollectionService tag on the mock, and the switch removes the old tag before adding the new one.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Player?>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 158,
                "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "PlayerMockUtils",
    "desc": "Mock identity: recognizing one, and finding the ones in the DataModel. Tag resolution is\nDataModel-scoped, so a mock is discoverable the moment it is parented in.\n\nEvery other helper guards its arguments with [PlayerMockUtils.isMock], so this module stays a leaf\n-- discovery keyed by a value only another helper can read lives with that helper instead (see\n[PlayerMockPlayerServiceUtils.getPlayerByUserId] and\n[PlayerMockCharacterUtils.getMockFromCharacter]).",
    "source": {
        "line": 13,
        "path": "src/player-mock/src/Shared/Helpers/PlayerMockUtils.lua"
    }
}