Setup
If you're running your tests in the browser bundled with webpack (or similar)
then DOM Testing Library
should work out of the box for you. However, most
people using DOM Testing Library
are using it with
the Jest testing framework with the testEnvironment
set
to
jest-environment-jsdom
(which is the default configuration with Jest).
Using Without Jest
jsdom is a pure JavaScript implementation of the DOM and browser APIs that runs in node. If you're not using Jest and you would like to run your tests in Node, then you must install jsdom yourself. There's also a package called global-jsdom which can be used to setup the global environment to simulate the browser APIs.
First, install jsdom and global-jsdom.
With mocha, the test command would look something like this: