Skip to content

๐Ÿ™ Simple and complete DOM testing utilities that encourage good testing practices.

License

Notifications You must be signed in to change notification settings

electroluxcode/dom-testing-library

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

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 Discord

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ลพฤ—

๐Ÿ’ป โš ๏ธ
Olzhas Askar
Olzhas Askar

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
Max Belsky
Max Belsky

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

โš ๏ธ
Tom Nagle
Tom Nagle

๐Ÿ’ป
Westbrook Johnson
Westbrook Johnson

๐Ÿ’ป
Mohammad Aziz
Mohammad Aziz

๐Ÿ’ป โš ๏ธ
seetdev
seetdev

โš ๏ธ ๐Ÿ’ป
Xavier Garcia Buils
Xavier Garcia Buils

๐Ÿ’ป โš ๏ธ
aw-davidson
aw-davidson

๐Ÿ’ป โš ๏ธ
Michaรซl De Boey
Michaรซl De Boey

๐Ÿ’ป
Minh Nguyen
Minh Nguyen

๐Ÿ’ป
Egill Sveinbjรถrnsson
Egill Sveinbjรถrnsson

๐Ÿ’ป
Pavel Pustovalov
Pavel Pustovalov

๐Ÿ“–
Adam Palaniuk
Adam Palaniuk

๐Ÿ’ป โš ๏ธ
Yama-Tomo
Yama-Tomo

๐Ÿ’ป โš ๏ธ
Aaron Pettengill
Aaron Pettengill

๐Ÿ’ป โš ๏ธ
Kate W. Boyd
Kate W. Boyd

๐Ÿ’ป
Rahul Suryakanth
Rahul Suryakanth

๐Ÿ’ป โš ๏ธ
Jamie
Jamie

๐Ÿ’ป โš ๏ธ
Nicolas Stepien
Nicolas Stepien

๐Ÿ’ป
Ken Powers
Ken Powers

๐Ÿ’ป
Michaล‚ Zdunek
Michaล‚ Zdunek

๐Ÿ’ป
Ali Nasserzadeh
Ali Nasserzadeh

๐Ÿ’ป
Darek Kay
Darek Kay

๐Ÿ“– ๐Ÿ’ป โš ๏ธ
Lukas
Lukas

๐Ÿ’ป โš ๏ธ
Tom Crockett
Tom Crockett

๐Ÿ’ป โš ๏ธ
Kevin Brewer
Kevin Brewer

๐Ÿ’ป โš ๏ธ
Ben Monro
Ben Monro

๐Ÿ’ป ๐Ÿค” โš ๏ธ ๐Ÿ“–
Stephan Meijer
Stephan Meijer

๐Ÿค” ๐Ÿ’ป โš ๏ธ
Joรฃo Forja
Joรฃo Forja

๐Ÿ’ป โš ๏ธ
Nick McCurdy
Nick McCurdy

๐Ÿ“– ๐Ÿ’ป โš ๏ธ ๐Ÿ‘€ ๐Ÿš‡
Caleb Meredith
Caleb Meredith

๐Ÿ’ป
Marco Moretti
Marco Moretti

๐Ÿ’ป โš ๏ธ ๐Ÿ‘€
Travis Jefferson
Travis Jefferson

๐Ÿ’ป โš ๏ธ
Maciej Jastrzebski
Maciej Jastrzebski

๐Ÿ›
Geoff Harcourt
Geoff Harcourt

๐Ÿ’ป
Josh Goldberg
Josh Goldberg

๐Ÿ’ป โš ๏ธ
Ken Gregory
Ken Gregory

๐Ÿ’ป โš ๏ธ
Jacob Paris
Jacob Paris

๐Ÿ’ป โš ๏ธ
keiya sasaki
keiya sasaki

๐Ÿ“–
Idan Entin
Idan Entin

๐Ÿ’ป โš ๏ธ
Deniz Susman
Deniz Susman

๐Ÿ’ป
Bianca Del Carretto
Bianca Del Carretto

โš ๏ธ ๐Ÿ’ป
Josh Lalonde
Josh Lalonde

๐Ÿ’ป โš ๏ธ
Ioannis Papadopoulos
Ioannis Papadopoulos

๐Ÿ’ป โš ๏ธ
Maxwell Newlands
Maxwell Newlands

๐Ÿ’ป โš ๏ธ
Jared Luxenberg
Jared Luxenberg

๐Ÿ’ป โš ๏ธ
snizhana
snizhana

๐Ÿ’ป โš ๏ธ
Michael van Engelshoven
Michael van Engelshoven

๐Ÿ‘€
Asher Tuggle
Asher Tuggle

๐Ÿ›
Winter LaMon
Winter LaMon

๐Ÿ’ป โš ๏ธ
Victor Cordova
Victor Cordova

๐Ÿ’ป โš ๏ธ
slowselfip
slowselfip

๐Ÿ›
Dmitry Semigradsky
Dmitry Semigradsky

๐Ÿ’ป
Adam
Adam

๐Ÿ’ป โš ๏ธ
balavishnuvj
balavishnuvj

๐Ÿ’ป
Chris Colborne
Chris Colborne

๐Ÿ’ป
Romain Trotard
Romain Trotard

๐Ÿ’ป
Thomas Marshall
Thomas Marshall

๐Ÿ’ป โš ๏ธ
johnjessewood
johnjessewood

๐Ÿ› ๐Ÿ’ป
Ari Perkkiรถ
Ari Perkkiรถ

๐Ÿ› ๐Ÿ’ป ๐Ÿ“–
Nathan Force
Nathan Force

๐Ÿ’ป
Philipp Fritsche
Philipp Fritsche

๐Ÿ’ป
Renato Alencar
Renato Alencar

๐Ÿ’ป โš ๏ธ
Simen Bekkhus
Simen Bekkhus

๐Ÿ›
Dan Abramov
Dan Abramov

๐Ÿ› ๐Ÿ‘€
Matan Borenkraout
Matan Borenkraout

๐Ÿ’ป
simcha90
simcha90

๐Ÿ’ป
Amit Miran
Amit Miran

๐Ÿš‡
Dominik Lesch
Dominik Lesch

๐Ÿ“–
Gareth Jones
Gareth Jones

๐Ÿ’ป โš ๏ธ
Rayat Rahman
Rayat Rahman

๐Ÿ’ป
Nik Savchenko
Nik Savchenko

๐Ÿ’ป
Kevin Fleischman
Kevin Fleischman

๐Ÿ’ป โš ๏ธ
Beth Hitch
Beth Hitch

๐Ÿ’ป
Jack Laurence
Jack Laurence

๐Ÿ’ป
SantoJambit
SantoJambit

๐Ÿ’ป
Yashu Mittal
Yashu Mittal

๐Ÿ“–
Ian VanSchooten
Ian VanSchooten

๐Ÿ’ป
Vanya Prokopovich
Vanya Prokopovich

๐Ÿ›
James Nail
James Nail

๐Ÿ›
Rob Caldecott
Rob Caldecott

๐Ÿ›
Dennis273
Dennis273

๐Ÿ’ป
Jackson Hardaker
Jackson Hardaker

โš ๏ธ
Robin Drexler
Robin Drexler

๐Ÿ’ป
Omer Dolev
Omer Dolev

๐Ÿ’ป
Lirlev48
Lirlev48

๐Ÿ’ป
Tarnay Kรกlmรกn
Tarnay Kรกlmรกn

๐Ÿ’ป
Than Hutchins
Than Hutchins

๐Ÿ’ป
Raphaรซl LEMIEUX
Raphaรซl LEMIEUX

๐Ÿ’ป
Arthur Lauck Vilas Boas
Arthur Lauck Vilas Boas

๐Ÿ“–
Daniel Acuรฑa
Daniel Acuรฑa

๐Ÿ’ป
Craig Morten
Craig Morten

๐Ÿ’ป ๐Ÿ’ฌ
Naor Peled
Naor Peled

๐Ÿ’ป
Julien Wajsberg
Julien Wajsberg

๐Ÿ’ป ๐Ÿ›
Kevin BON
Kevin BON

๐Ÿ’ป ๐Ÿ›

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

LICENSE

MIT

About

๐Ÿ™ Simple and complete DOM testing utilities that encourage good testing practices.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.3%
  • TypeScript 22.7%