Testing Library

Testing Library

  • Docs
  • Recipes
  • Help
  • Blog

›DOM Testing Library

Getting Started

  • Introduction
  • Guiding Principles
  • Using Fake Timers

Frameworks

    DOM Testing Library

    • Introduction
    • Install
    • Example
    • Setup
    • Queries
    • Firing Events
    • Async Utilities
    • Helpers
    • Configuration
    • FAQ
    • Cheatsheet

    React Testing Library

    • Introduction
    • Example
    • Setup
    • API
    • Migrate from Enzyme
    • FAQ
    • Cheatsheet

    Reason Testing Library

    • Introduction
    • Examples

    React Native Testing Library

    • Introduction
    • Example
    • Setup

    Vue Testing Library

    • Introduction
    • Examples
    • Setup
    • API
    • Cheatsheet
    • FAQ

    Marko Testing Library

    • Introduction
    • Setup
    • API

    Angular Testing Library

    • Introduction
    • Examples
    • API

    Preact Testing Library

    • Introduction
    • Example
    • API
    • Learn

    Svelte Testing Library

    • Introduction
    • Setup
    • Example
    • API
  • Cypress Testing Library
  • Puppeteer Testing Library
  • Testcafe Testing Library
  • Nightwatch Testing Library

Ecosystem

  • user-event
  • jest-dom
  • bs-jest-dom
  • jest-native
  • react-select-event
  • eslint-plugin-testing-library
  • eslint-plugin-jest-dom
  • riot-testing-library
  • jasmine-dom
Edit

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:

  • 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:

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 7/31/2020
← IntroductionExample →
  • Wrappers
  • Ecosystem
  • Main Exports
Testing Library
Docs
Getting StartedExamplesAPIHelp
Community
BlogStack OverflowDiscord
More
StarGitHubEdit Docs on GitHubHosted by Netlify
Copyright © 2018-2020 Kent C. Dodds and contributors