Simple and complete DOM testing utilities that encourage good testing practices.
Build Status Code Coverage version downloads MIT License All Contributors PRs Welcome Code of Conduct Discord
Watch on GitHub Star on GitHub Tweet
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.
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.
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
Read the docs (and discover framework and tool-specific implementations) at testing-library.com
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:
- If it relates to rendering components, it deals with DOM nodes rather than component instances, nor should it encourage dealing with component instances.
- 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.
- 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.
Thanks goes to these people (emoji key):
Kent C. Dodds
π» π π
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
π¦ Anto Aravinth
Anto Aravinth
π»
Jonah Moses
π Εukasz Gandecki
Εukasz Gandecki
π»
Ivan Babak
π π€ π» π Jesse Day
Jesse Day
π» Ernesto GarcΓa
Ernesto GarcΓa
π¬ π» π
Josef Maxx Blake
π» π
Alex Cook
π π‘ π Daniel Cook
Daniel Cook
π» π
Thomas Chia
π π» Tim Deschryver
Tim Deschryver
π»
Alex Krolick
π» Maddi Joyce
Maddi Joyce
π»
Peter Kamps
π π»
Jonathan Stoye
π π» Sanghyeon Lee
Sanghyeon Lee
π‘ Justice Mba
Justice Mba
π» π π€ Wayne Crouch
Wayne Crouch
π» Ben Elliott
Ben Elliott
π» Ruben Costa
Ruben Costa
π»
Robert Smith
π π€ π dadamssg
dadamssg
π» Neil Kistner
Neil Kistner
π»
Ben Chauvette
π» Jeff Baumgardt
Jeff Baumgardt
π» π Matan Kushner
Matan Kushner
π» π π€
Alex Wendte
π» π
Tamas Fodor
π Benjamin Eckardt
Benjamin Eckardt
π» Ryan Campbell
Ryan Campbell
π Taylor Briggs
Taylor Briggs
John Gozde
π» C. T. Lin
C. T. Lin
π Terrence Wong
Terrence Wong
π»
Soo Jae Hwang
π» Royston Shufflebotham
Royston Shufflebotham
π π» π
Vadim Brodsky
π» Eunjae Lee
Eunjae Lee
π» David Peter
David Peter
π» Shy Alter
Shy Alter
π» π Εukasz Makuch
Εukasz Makuch
π¦
Tyler Haas
π»
Vesa Laakso
π»
Tulsi Sapkota
π» Tiago Nunes
Tiago Nunes
π»
JaxCavalera
π» π bopfer
bopfer
Jan Pfitzner
π»
David
π» Diego Hernandez
Diego Hernandez
π»
Alex Young
π» Paul Armstrong
Paul Armstrong
π»
TamΓ‘s SzabΓ³
π»
Dylan Piercey
π»
Michael Lasky
π»
Sebastian Silbermann
π»
Dylan Vann
π» AdriΓ Fontcuberta
AdriΓ Fontcuberta
π»
Thomas Lombart
π» Sam Horton
Sam Horton
π»
Andrew Hill
π» Jan Amann
Jan Amann
π»
Brais PiΓ±eiro
π»
Dominykas BlyΕΎΔ
π»
Olzhas Askar
π»
Max Belsky
π»
Michael Mantel
Tom Nagle
π» Westbrook Johnson
Westbrook Johnson
π»
Mohammad Aziz
π»
seetdev
Xavier Garcia Buils
π»
aw-davidson
π»
MichaΓ«l De Boey
π» Minh Nguyen
Minh Nguyen
π» Egill SveinbjΓΆrnsson
Egill SveinbjΓΆrnsson
π»
Pavel Pustovalov
π Adam Palaniuk
Adam Palaniuk
π»
Yama-Tomo
π»
Aaron Pettengill
π»
Kate W. Boyd
π» Rahul Suryakanth
Rahul Suryakanth
π»
Jamie
π»
Nicolas Stepien
π» Ken Powers
Ken Powers
π» MichaΕ Zdunek
MichaΕ Zdunek
π» Ali Nasserzadeh
Ali Nasserzadeh
π» Darek Kay
Darek Kay
π π»
Lukas
π»
Tom Crockett
π»
Kevin Brewer
π»
Ben Monro
π» π€
Stephan Meijer
π€ π»
JoΓ£o Forja
π»
Nick McCurdy
π π»
Caleb Meredith
π» Marco Moretti
Marco Moretti
π»
Travis Jefferson
π»
Maciej Jastrzebski
π Geoff Harcourt
Geoff Harcourt
π» Josh Goldberg
Josh Goldberg
π»
Ken Gregory
π»
Jacob Paris
π»
keiya sasaki
π
Idan Entin
π»
Deniz Susman
π» Bianca Del Carretto
Bianca Del Carretto
Josh Lalonde
π»
Ioannis Papadopoulos
π»
Maxwell Newlands
π»
Jared Luxenberg
π»
snizhana
π»
Michael van Engelshoven
π Asher Tuggle
Asher Tuggle
π Winter LaMon
Winter LaMon
π»
Victor Cordova
π»
slowselfip
π Dmitry Semigradsky
Dmitry Semigradsky
π»
Adam
π»
balavishnuvj
π» Chris Colborne
Chris Colborne
π» Romain Trotard
Romain Trotard
π» Thomas Marshall
Thomas Marshall
π»
johnjessewood
π π» Ari PerkkiΓΆ
Ari PerkkiΓΆ
π π» π
Nathan Force
π» Philipp Fritsche
Philipp Fritsche
π» Renato Alencar
Renato Alencar
π»
Simen Bekkhus
π Dan Abramov
Dan Abramov
π π Matan Borenkraout
Matan Borenkraout
π» simcha90
simcha90
π»
Amit Miran
π Dominik Lesch
Dominik Lesch
π Gareth Jones
Gareth Jones
π»
Rayat Rahman
π» Nik Savchenko
Nik Savchenko
π» Kevin Fleischman
Kevin Fleischman
π»
Beth Hitch
π»
Jack Laurence
π» SantoJambit
SantoJambit
π» Yashu Mittal
Yashu Mittal
π Ian VanSchooten
Ian VanSchooten
π» Vanya Prokopovich
Vanya Prokopovich
π James Nail
James Nail
π Rob Caldecott
Rob Caldecott
π
This project follows the all-contributors specification. Contributions of any kind welcome!