1.11.0 • Published 9 months ago
@myprofile/test-helpers v1.11.0
@myprofile/test-helpers
A collection of helpful testing functions based on React Testing Library.
Usage
setupRender
setupRender
accepts a component and default props, and returns a render
function that will merge additional props to the component.
import { screen, setupRender } from "../../test-helpers";
const render = setupRender(<Component />, { text: "default props" });
describe("setupRender", () => {
test("default props", () => {
render();
expect(screen.getByText("default prop")).toBeInTheDocument();
});
test("default props", () => {
render({ moreText: "more props" });
expect(screen.getByText("default props")).toBeInTheDocument();
expect(screen.getByText("more props")).toBeInTheDocument();
});
});