@roku-sdk/testing-library
v2.19.1
Published
Roku typescript testing library
Keywords
Readme
@roku-sdk/testing-library
Unit-test utilities for RSG SDK components, in the style of React Testing Library. Tests render a component into an in-memory node tree that mirrors the SceneGraph tree it would build on a device, query that tree by tag or by prop, fire events at it, and run under Jest with no Roku attached.
Install
pnpm add @roku-sdk/testing-libraryApps created with rk create already include it, together with a Jest configuration from @roku-sdk/dev-tools.
Usage
import { render, TestAnchorNode } from "@roku-sdk/testing-library";
import MyScreen from "./my-screen";
const TestMyScreen = TestAnchorNode(MyScreen);
test("shows the title", async () => {
const { getByProp, dispose } = await render(() => <TestMyScreen />);
getByProp("text", "Welcome");
await dispose();
});Documentation
- RSG testing library — queries, events, transactions and testing a
TsComponent - Full SDK documentation
