React Testing Examples

react-testing-library
GitHubAbout
All examples

Minimal setup required to use react-testing-library with Jest.

All examples featured here run using these exact config files.

jest.config.js
module.exports = {
setupFilesAfterEnv: ['./rtl.setup.js']
};
module.exports = {
  setupFilesAfterEnv: ['./rtl.setup.js']
};
rtl.setup.js
// See https://github.com/kentcdodds/react-testing-library#global-config
import 'jest-dom/extend-expect';
import 'react-testing-library/cleanup-after-each';
// See https://github.com/kentcdodds/react-testing-library#global-config
import 'jest-dom/extend-expect';
import 'react-testing-library/cleanup-after-each';