Install
This module is distributed via npm which is bundled with node and
should be installed as one of your project's devDependencies:
Wrappers
If you are using a framework or library such as React, you will likely want to install the wrapper:
- React Testing Library
- Reason Testing Library
- React Native Testing Library
- Vue Testing Library
- Marko Testing Library
- Angular Testing Library
- Preact Testing Library
- Svelte Testing Library
- Cypress Testing Library
- Puppeteer Testing Library
- Testcafe Testing Library
- Nightwatch Testing Library
Ecosystem
DOM Testing Library works well with these companion libraries:
- user-event browser event simulation
- jest-dom custom Jest matchers
- bs-jest-dom companion library for
bs-react-testing-library - jest-native companion library for
React Native Testing Library - react-select-event companion library for
React Testing Library - eslint-plugin-testing-library ESLint plugin for Testing Library
- eslint-plugin-jest-dom ESLint plugin for Jest DOM
- riot-testing-library adds APIs for working with Riot.js components
Main Exports
You can
review the DOM Testing Library package.json here.
In particular, the main, module, and umd:main fields are useful. Each of
these points to a file that's useful in certain situations. Typically, your
testing framework will resolve to the correct one for your situation, but if it
does not, then you can either configure your testing framework to resolve to the
right file when you require/import @testing-library/dom or you can import the
file you need more explicitly. For example:
You can
review the published dist files here.
The main file is configured to compile down to support the version of node
that is referenced in the package.json engines.node field. But the module
and umd:main files are configured to compile down to support browsers as old
as IE 10.