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

viniciuslagedo/dom-testing-library

Β 
Β 

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

πŸ’» πŸ“– πŸš‡ ⚠️

Greg BergΓ©

πŸ€”

Ryan Castner

πŸ“–

Daniel Sandiego

πŸ’»

PaweΕ‚ MikoΕ‚ajczyk

πŸ’»

Alejandro ÑÑñez Ortiz

πŸ“–

Matt Parrish

πŸ› πŸ’» πŸ“– ⚠️

Justin Hall

πŸ“¦

Anto Aravinth

πŸ’» ⚠️ πŸ“–

Jonah Moses

πŸ“–

Łukasz Gandecki

πŸ’» ⚠️ πŸ“–

Ivan Babak

πŸ› πŸ€” πŸ’» πŸ“–

Jesse Day

πŸ’»

Ernesto GarcΓ­a

πŸ’¬ πŸ’» πŸ“–

Josef Maxx Blake

πŸ’» πŸ“– ⚠️

Alex Cook

πŸ“– πŸ’‘ πŸ‘€

Daniel Cook

πŸ’» πŸ“– ⚠️

Thomas Chia

πŸ› πŸ’»

Tim Deschryver

πŸ’» ⚠️ πŸ‘€

Alex Krolick

πŸ’»

Maddi Joyce

πŸ’»

Peter Kamps

πŸ› πŸ’» ⚠️

Jonathan Stoye

πŸ“– πŸ’»

Sanghyeon Lee

πŸ’‘

Justice Mba

πŸ’» πŸ“– πŸ€”

Wayne Crouch

πŸ’»

Ben Elliott

πŸ’»

Ruben Costa

πŸ’»

Robert Smith

πŸ› πŸ€” πŸ“–

dadamssg

πŸ’»

Neil Kistner

πŸ’» ⚠️

Ben Chauvette

πŸ’»

Jeff Baumgardt

πŸ’» πŸ“–

Matan Kushner

πŸ’» πŸ“– πŸ€” ⚠️

Alex Wendte

πŸ’» πŸ“– ⚠️

Tamas Fodor

πŸ“–

Benjamin Eckardt

πŸ’»

Ryan Campbell

πŸ“–

Taylor Briggs

⚠️

John Gozde

πŸ’»

C. T. Lin

πŸ“–

Terrence Wong

πŸ’»

Soo Jae Hwang

πŸ’»

Royston Shufflebotham

πŸ› πŸ’» πŸ“– ⚠️

Vadim Brodsky

πŸ’»

Eunjae Lee

πŸ’»

David Peter

πŸ’»

Shy Alter

πŸ’» πŸ“–

Łukasz Makuch

πŸ“¦

Tyler Haas

πŸ’» ⚠️

Vesa Laakso

πŸ’» ⚠️

Tulsi Sapkota

πŸ’»

Tiago Nunes

πŸ’» ⚠️

JaxCavalera

πŸ’» πŸ‘€

bopfer

⚠️

Jan Pfitzner

πŸ’»

David

πŸ’»

Diego Hernandez

πŸ’» ⚠️

Alex Young

πŸ’»

Paul Armstrong

πŸ’» ⚠️

TamΓ‘s SzabΓ³

πŸ’» ⚠️

Dylan Piercey

πŸ’» ⚠️

Michael Lasky

πŸ’» ⚠️ πŸ“–

Sebastian Silbermann

πŸ’» ⚠️ πŸ“– πŸš‡ πŸ‘€

Dylan Vann

πŸ’»

AdriΓ  Fontcuberta

πŸ’» ⚠️ πŸ“–

Thomas Lombart

πŸ’»

Sam Horton

πŸ’» ⚠️

Andrew Hill

πŸ’»

Jan Amann

πŸ’» ⚠️

Brais PiΓ±eiro

πŸ’» ⚠️

Dominykas BlyΕΎΔ—

πŸ’» ⚠️

Olzhas Askar

πŸ’» ⚠️ πŸ“–

Max Belsky

πŸ’» ⚠️

Michael Mantel

⚠️

Tom Nagle

πŸ’»

Westbrook Johnson

πŸ’»

Mohammad Aziz

πŸ’» ⚠️

seetdev

⚠️ πŸ’»

Xavier Garcia Buils

πŸ’» ⚠️

aw-davidson

πŸ’» ⚠️

MichaΓ«l De Boey

πŸ’»

Minh Nguyen

πŸ’»

Egill SveinbjΓΆrnsson

πŸ’»

Pavel Pustovalov

πŸ“–

Adam Palaniuk

πŸ’» ⚠️

Yama-Tomo

πŸ’» ⚠️

Aaron Pettengill

πŸ’» ⚠️

Kate W. Boyd

πŸ’»

Rahul Suryakanth

πŸ’» ⚠️

Jamie

πŸ’» ⚠️

Nicolas Stepien

πŸ’»

Ken Powers

πŸ’»

MichaΕ‚ Zdunek

πŸ’»

Ali Nasserzadeh

πŸ’»

Darek Kay

πŸ“– πŸ’» ⚠️

Lukas

πŸ’» ⚠️

Tom Crockett

πŸ’» ⚠️

Kevin Brewer

πŸ’» ⚠️

Ben Monro

πŸ’» πŸ€” ⚠️ πŸ“–

Stephan Meijer

πŸ€” πŸ’» ⚠️

JoΓ£o Forja

πŸ’» ⚠️

Nick McCurdy

πŸ“– πŸ’» ⚠️ πŸ‘€ πŸš‡

Caleb Meredith

πŸ’»

Marco Moretti

πŸ’» ⚠️ πŸ‘€

Travis Jefferson

πŸ’» ⚠️

Maciej Jastrzebski

πŸ›

Geoff Harcourt

πŸ’»

Josh Goldberg

πŸ’» ⚠️

Ken Gregory

πŸ’» ⚠️

Jacob Paris

πŸ’» ⚠️

keiya sasaki

πŸ“–

Idan Entin

πŸ’» ⚠️

Deniz Susman

πŸ’»

Bianca Del Carretto

⚠️ πŸ’»

Josh Lalonde

πŸ’» ⚠️

Ioannis Papadopoulos

πŸ’» ⚠️

Maxwell Newlands

πŸ’» ⚠️

Jared Luxenberg

πŸ’» ⚠️

snizhana

πŸ’» ⚠️

Michael van Engelshoven

πŸ‘€

Asher Tuggle

πŸ›

Winter LaMon

πŸ’» ⚠️

Victor Cordova

πŸ’» ⚠️

slowselfip

πŸ›

Dmitry Semigradsky

πŸ’»

Adam

πŸ’» ⚠️

balavishnuvj

πŸ’»

Chris Colborne

πŸ’»

Romain Trotard

πŸ’»

Thomas Marshall

πŸ’» ⚠️

johnjessewood

πŸ› πŸ’»

Ari PerkkiΓΆ

πŸ› πŸ’» πŸ“–

Nathan Force

πŸ’»

Philipp Fritsche

πŸ’»

Renato Alencar

πŸ’» ⚠️

Simen Bekkhus

πŸ›

Dan Abramov

πŸ› πŸ‘€

Matan Borenkraout

πŸ’»

simcha90

πŸ’»

Amit Miran

πŸš‡

Dominik Lesch

πŸ“–

Gareth Jones

πŸ’» ⚠️

Rayat Rahman

πŸ’»

Nik Savchenko

πŸ’»

Kevin Fleischman

πŸ’» ⚠️

Beth Hitch

πŸ’»

Jack Laurence

πŸ’»

SantoJambit

πŸ’»

Yashu Mittal

πŸ“–

Ian VanSchooten

πŸ’»

Vanya Prokopovich

πŸ›

James Nail

πŸ›

Rob Caldecott

πŸ›

Dennis273

πŸ’»

Jackson Hardaker

⚠️

Robin Drexler

πŸ’»

Omer Dolev

πŸ’»

Lirlev48

πŸ’»

Tarnay KΓ‘lmΓ‘n

πŸ’»

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 80.1%
  • TypeScript 19.9%