Skip to content
๐Ÿ™ Simple and complete DOM testing utilities that encourage good testing practices.
JavaScript
Branch: master
Clone or download
Pull request Compare This branch is 40 commits behind testing-library:master.
Fetching latest commitโ€ฆ
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
other
src
tests
.all-contributorsrc
.gitattributes
.gitignore
.npmrc
.prettierignore
.prettierrc
.travis.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
jest.config.js
package.json
rollup.config.js

README.md

DOM Testing Library

octopus

Simple and complete DOM testing utilities that encourage good testing practices.

Read the docs | Edit the docs


Build Status Code Coverage version downloads MIT License

All Contributors PRs Welcome Code of Conduct

Watch on GitHub Star on GitHub Tweet

Table of Contents

The Problem

You want to write maintainable tests for your Web UI. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your testbase to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.

This Solution

The DOM Testing Library is a very light-weight solution for testing DOM nodes (whether simulated with JSDOM as provided by default with Jest or in the browser). The main utilities it provides involve querying the DOM for nodes in a way that's similar to how the user finds elements on the page. In this way, the library helps ensure your tests give you confidence in your UI code. The DOM Testing Library's primary guiding principle is:

The more your tests resemble the way your software is used, the more confidence they can give you.

Installation

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

Docs

Documentation

Read the docs (and discover framework and tool-specific implementations) at testing-library.com

Guiding Principles

The more your tests resemble the way your software is used, the more confidence they can give you.

We try to only expose methods and utilities that encourage you to write tests that closely resemble how your web pages are used.

Utilities are included in this project based on the following guiding principles:

  1. If it relates to rendering components, it deals with DOM nodes rather than component instances, nor should it encourage dealing with component instances.
  2. It should be generally useful for testing the application components in the way the user would use it. We are making some trade-offs here because we're using a computer and often a simulated browser environment, but in general, utilities should encourage tests that use the components the way they're intended to be used.
  3. Utility implementations and APIs should be simple and flexible.

At the end of the day, what we want is for this library to be pretty light-weight, simple, and understandable.

Contributors

Thanks goes to these people (emoji key):

Kent C. Dodds
Kent C. Dodds

๐Ÿ’ป ๐Ÿ“– ๐Ÿš‡ โš ๏ธ
Greg Bergรฉ
Greg Bergรฉ

๐Ÿค”
Ryan Castner
Ryan Castner

๐Ÿ“–
Daniel Sandiego
Daniel Sandiego

๐Ÿ’ป
Paweล‚ Mikoล‚ajczyk
Paweล‚ Mikoล‚ajczyk

๐Ÿ’ป
Alejandro ร‘รกรฑez Ortiz
Alejandro ร‘รกรฑez Ortiz

๐Ÿ“–
Matt Parrish
Matt Parrish

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– โš ๏ธ
Justin Hall
Justin Hall

๐Ÿ“ฆ
Anto Aravinth
Anto Aravinth

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
Jonah Moses
Jonah Moses

๐Ÿ“–
ลukasz Gandecki
ลukasz Gandecki

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
Ivan Babak
Ivan Babak

๐Ÿ› ๐Ÿค” ๐Ÿ’ป ๐Ÿ“–
Jesse Day
Jesse Day

๐Ÿ’ป
Ernesto Garcรญa
Ernesto Garcรญa

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿ“–
Josef Maxx Blake
Josef Maxx Blake

๐Ÿ’ป ๐Ÿ“– โš ๏ธ
Alex Cook
Alex Cook

๐Ÿ“– ๐Ÿ’ก ๐Ÿ‘€
Daniel Cook
Daniel Cook

๐Ÿ’ป ๐Ÿ“– โš ๏ธ
Thomas Chia
Thomas Chia

๐Ÿ› ๐Ÿ’ป
Tim Deschryver
Tim Deschryver

๐Ÿ’ป โš ๏ธ
Alex Krolick
Alex Krolick

๐Ÿ’ป
Maddi Joyce
Maddi Joyce

๐Ÿ’ป
Peter Kamps
Peter Kamps

๐Ÿ› ๐Ÿ’ป โš ๏ธ
Jonathan Stoye
Jonathan Stoye

๐Ÿ“–
Sanghyeon Lee
Sanghyeon Lee

๐Ÿ’ก
Justice Mba
Justice Mba

๐Ÿ’ป ๐Ÿ“– ๐Ÿค”
Wayne Crouch
Wayne Crouch

๐Ÿ’ป
Ben Elliott
Ben Elliott

๐Ÿ’ป
Ruben Costa
Ruben Costa

๐Ÿ’ป
Robert Smith
Robert Smith

๐Ÿ› ๐Ÿค” ๐Ÿ“–
dadamssg
dadamssg

๐Ÿ’ป
Neil Kistner
Neil Kistner

๐Ÿ’ป
Ben Chauvette
Ben Chauvette

๐Ÿ’ป
Jeff Baumgardt
Jeff Baumgardt

๐Ÿ’ป ๐Ÿ“–
Matan Kushner
Matan Kushner

๐Ÿ’ป ๐Ÿ“– ๐Ÿค” โš ๏ธ
Alex Wendte
Alex Wendte

๐Ÿ’ป ๐Ÿ“– โš ๏ธ
Tamas Fodor
Tamas Fodor

๐Ÿ“–
Benjamin Eckardt
Benjamin Eckardt

๐Ÿ’ป
Ryan Campbell
Ryan Campbell

๐Ÿ“–
Taylor Briggs
Taylor Briggs

โš ๏ธ
John Gozde
John Gozde

๐Ÿ’ป
C. T. Lin
C. T. Lin

๐Ÿ“–
Terrence Wong
Terrence Wong

๐Ÿ’ป
Soo Jae Hwang
Soo Jae Hwang

๐Ÿ’ป
Royston Shufflebotham
Royston Shufflebotham

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– โš ๏ธ
Vadim Brodsky
Vadim Brodsky

๐Ÿ’ป
Eunjae Lee
Eunjae Lee

๐Ÿ’ป
David Peter
David Peter

๐Ÿ’ป
Shy Alter
Shy Alter

๐Ÿ’ป ๐Ÿ“–
ลukasz Makuch
ลukasz Makuch

๐Ÿ“ฆ
Tyler Haas
Tyler Haas

๐Ÿ’ป โš ๏ธ
Vesa Laakso
Vesa Laakso

๐Ÿ’ป โš ๏ธ
Tulsi Sapkota
Tulsi Sapkota

๐Ÿ’ป
Tiago Nunes
Tiago Nunes

๐Ÿ’ป โš ๏ธ
JaxCavalera
JaxCavalera

๐Ÿ’ป ๐Ÿ‘€
bopfer
bopfer

โš ๏ธ
Jan Pfitzner
Jan Pfitzner

๐Ÿ’ป
David
David

๐Ÿ’ป
Diego Hernandez
Diego Hernandez

๐Ÿ’ป โš ๏ธ
Alex Young
Alex Young

๐Ÿ’ป
Paul Armstrong
Paul Armstrong

๐Ÿ’ป โš ๏ธ
Tamรกs Szabรณ
Tamรกs Szabรณ

๐Ÿ’ป โš ๏ธ
Dylan Piercey
Dylan Piercey

๐Ÿ’ป โš ๏ธ
Michael Lasky
Michael Lasky

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
Sebastian Silbermann
Sebastian Silbermann

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
Dylan Vann
Dylan Vann

๐Ÿ’ป
Adriร  Fontcuberta
Adriร  Fontcuberta

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
Thomas Lombart
Thomas Lombart

๐Ÿ’ป
Sam Horton
Sam Horton

๐Ÿ’ป โš ๏ธ
Andrew Hill
Andrew Hill

๐Ÿ’ป
Jan Amann
Jan Amann

๐Ÿ’ป โš ๏ธ
Brais Piรฑeiro
Brais Piรฑeiro

๐Ÿ’ป โš ๏ธ
Dominykas Blyลพฤ—
Dominykas Blyลพฤ—

๐Ÿ’ป โš ๏ธ

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

MIT

You canโ€™t perform that action at this time.