3.13.2-ts.3 • Published 5 months ago
@rbxts-js/jest-mock-rbx v3.13.2-ts.3
jest-mock-rbx
No upstream. Roblox only.
This package implements Jest's data model mocking capabilities for Roblox:
InstanceProxy, used for constructing objects that act like an existing instance, except actions can be intercepted and mocked.DataModelMocker, provides higher-level proxies that can interact with each other as part of a fake data model.
:pencil2: Notes
- Right now, only a limited subset of data model mocking features are implemented and available for use.
DataModelMockershould be used for constructing instance mocks, notInstanceProxy. TheInstanceProxyclass is a minimal, self-contained implementation with no special behaviour. TheDataModelMockerclass allows proxies to be reused, and provides useful default mock behaviour like returning proxied descendants or ancestry.InstanceProxyintentionally only implements some of anInstance's capabilities. It is assumed that the instance proxy is being used on normal, idiomatic code that would correctly function if given anInstance. Instance proxies have normal reference-based equality. They are not equal to the original instance, nor to any other proxies of that instance. Instance proxies can't be consumed by functions expecting a "proper Instance". In particular, calls to C such asx:IsAncestorOf(InstanceProxy)will error as these calls are not mockable.