@mysetup/test-helpers
v2.0.10
Published
Shared React and Apollo test helpers for application packages.
Maintainers
Readme
@mysetup/test-helpers
Testing utilities built on top of React Testing Library, jest-axe, and Apollo testing helpers.
Installation
pnpm add -D @mysetup/test-helpers react react-domSupported libraries and runtimes
| Supported | Notes | | --------------------- | ---------------------------- | | Jest + jsdom | Supported | | React Testing Library | Supported | | Next.js test suites | Supported | | Vitest | Not targeted by this package |
Usage
import { screen, setupRender } from "@mysetup/test-helpers";
function Component({ text }: { text: string }) {
return <div>{text}</div>;
}
const render = setupRender(Component, { text: "default value" });
test("renders merged props", () => {
render({ text: "overridden" });
expect(screen.getByText("overridden")).toBeInTheDocument();
});Exports
setupRendersetupRenderWithProvidersetupRenderHooksetupRenderHookWithProviderMockedProvider- Testing Library re-exports
jest-axere-exports
Notes
- This package currently uses
@jest/globalsand mocksnext/navigation, so it is designed for Jest-based test setups. - If your app uses Vite, this package is suitable when your tests run on Jest rather than Vitest.
