The React Testing Library is a very light-weight solution for testing React components. It provides light utility functions on top of
react-dom/test-utils, in a way that encourages better testing practices.
superplate's plugin of React Testing Library is built on top of superplate's Jest plugin and automatically includes necessary wrappers and imports to run your component tests.
You can see how superplate's React Testing Library plugin is implemented below.
Configuration for Jest is not included. Please check out Jest Plugin to learn more about our Jest configuration.
We may need to wrap our test components to context providers, data stores etc. It's a good practice to make this wrappers globally available. We will create a custom render and re-export everything from
React Testing Library in
We will use Jest as our test runner. If Jest is already set up you can simply run:
All this work will be handled automatically by superplate, so you don’t need to do anything extra as long as you choose testing-library as testing plugin during the project creation phase.
If you want to add React Testing Library to your existing project first install the dependencies
Then you can follow documentations for detail usage