Utilities for testing React components. It's based on [`@testing-library/react`](https://testing-library.com/react) which provides light utility functions on top of [`react-dom`](https://reactjs.org/docs/react-dom.html) and [`react-dom/test-utils`](https:
npm install @matejbransky/react-test-utilsUtilities for testing React components. It's based on @testing-library/react which provides light utility functions on top of react-dom and react-dom/test-utils in a way that encourages better testing practices. Its primary guiding principle is:
> The more your tests resemble the way your software is used, the more confidence they can give you.
In addition to reexported utilities @matejbransky/react-test-utils enhances API and adds another useful functions.
Requirements:
- Node.js
- npm/Yarn
- TypeScript
- jest
- @matejbransky/jest-preset
Installation:
```
yarn add @matejbransky/react-test-utils
It's enhanced version of the original rerender() method from @testing-library/react. Enhanced version accepts only new components props so you don't need to repeat JSX signature with all original props + new props.
Example:
`jsx
const { rerender } = render(
// re-render the same component with the original props and new props
rerender({ name: 'Bongo' });
`
_Note: component's ref persists rerenders thanks to the React.cloneElement()` method._