Install

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev @testing-library/dom

Wrappers

If you are using a framework or library such as React, you will likely want to install the wrapper:

Ecosystem

DOM Testing Library works well with these companion libraries:

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:

import {within} from '@testing-library/dom/dist/@testing-library/dom.umd.js'

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.

Last updated on by Nick McCurdy