Testing Library React is a library that allows us to test React components in a more user-friendly way, simulating the behavior of a user interacting with the component.
- Here we have all the objects of the @testing-library/react package
| Object | Description | Example |
|---|---|---|
| render | is used to render the component in a virtual DOM, so we can test it without having to render it in the real DOM. | const {container} = render(<CounterApp value={initialValue} />); expect(container).toMatchSnapshot(); |
| screen | is a global object that contains all the queries that we can use to get the elements of the component rendered previously with render. | render(``); expect(screen.getByText(initialValue)).toBeTruthy(); |
