@mysetup/test-helpers
v1.7.0
Published
A collection of helpful testing functions based on [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/).
Downloads
562
Readme
@mysetup/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();
});
});