MessagingServiceMock
In-memory stand-in for Roblox's MessagingService used by tests. It provides in-process
loopback: a MessagingServiceMock.PublishAsync on a topic delivers the message to every
current subscriber of that topic on the next task step, shaped exactly like the real
MessagingService delivers it ({ Data = message, Sent = <number> }).
Messages are round-tripped through JSON on delivery (mimicking the real serialization), so aliasing bugs surface the same way they would against the real service.
It is injected into a PlaceMessagingService via
PlaceMessagingService.SetRobloxMessagingService so tests never touch the real
MessagingService.
local messagingService = MessagingServiceMock.new()
placeMessagingService:SetRobloxMessagingService(messagingService)
Functions
isMessagingServiceMock
MessagingServiceMock.isMessagingServiceMock(value: any) → booleanReturns whether the given value is a MessagingServiceMock.
new
Constructs a new MessagingServiceMock.
PublishAsync
Mimics MessagingService:PublishAsync. Delivers the message to every current subscriber of the
topic on the next task step, shaped as { Data = message, Sent = <number> }. The message is
round-tripped through JSON, mimicking the real service's serialization.
SubscribeAsync
MessagingServiceMock.SubscribeAsync() → {Connected: boolean,Disconnect: () → (),Destroy: () → ()}
Mimics MessagingService:SubscribeAsync. Returns a connection-like object that removes the
subscriber when disconnected (or destroyed by a [Maid]).