React Testing Library is a package that offers a set of utilities to makes testing React applications simple by enforcing good practices and offering a small but very powerful set of APIs. It leverages
react-dom/test-utils under the hood and exposes APIs tailored to work with React components.
We try to only expose methods and utilities that encourage you to write tests that closely resemble how your web pages are used.
Utilities are included in this project based on the following guiding principles:
- If it relates to rendering components, then it should deal with DOM nodes rather than component instances, and it should not encourage dealing with component instances.
- It should be generally useful for testing the application components in the way the user would use it. We are making some trade-offs here because we're using a computer and often a simulated browser environment, but in general, utilities should encourage tests that use the components the way they're intended to be used.
- Utility implementations and APIs should be simple and flexible.
- Q: does
react-testing-libraryis a substitute to Jest?
A: No they complement each other
react-testing-librarybe used without Jest?
Q: I'm testing using
Enzymeshould I switch?
A: It depends, they solve some of the same problems in very different ways but also have differences and unique features not available to the other
react-testing-librarycoexist is a project using
- A: Yes, is possible to use both in the same file
Author: Jaga Santagostino