Scene queries
Find display objects by their label property, decoupling tests from scene graph hierarchy.
getByLabel(root, label)
Section titled “getByLabel(root, label)”Throws if the label is not found.
const { container } = mountScene(() => ( <Container label="scene"> <Sprite label="player" /> </Container>));
const player = getByLabel(container, "player");expect(player.x).toBe(100);queryByLabel(root, label)
Section titled “queryByLabel(root, label)”Same as getByLabel but returns undefined instead of throwing.
const maybe = queryByLabel(container, "missing-label"); // undefinedgetAllByLabel(root, label)
Section titled “getAllByLabel(root, label)”Find all display objects with the given label.
const enemies = getAllByLabel(container, "enemy");expect(enemies).toHaveLength(3);