• Stars
    star
    3,271
  • Rank 13,729 (Top 0.3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

πŸ’» πŸ›

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

LICENSE

MIT

More Repositories

1

react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.
JavaScript
18,952
star
2

react-hooks-testing-library

🐏 Simple and complete React hooks testing utilities that encourage good testing practices.
TypeScript
5,083
star
3

jest-dom

πŸ¦‰ Custom jest matchers to test the state of the DOM
JavaScript
4,422
star
4

user-event

πŸ• Simulate user events
TypeScript
2,181
star
5

cypress-testing-library

πŸ… Simple and complete custom Cypress commands and utilities that encourage good testing practices.
JavaScript
1,798
star
6

vue-testing-library

🦎 Simple and complete Vue.js testing utilities that encourage good testing practices.
JavaScript
1,071
star
7

eslint-plugin-testing-library

ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library
TypeScript
979
star
8

testing-playground

Simple and complete DOM testing playground that encourage good testing practices.
JavaScript
776
star
9

angular-testing-library

πŸ¦” Simple and complete Angular testing utilities that encourage good testing practices
TypeScript
626
star
10

svelte-testing-library

🐿️ Simple and complete Svelte DOM testing utilities that encourage good testing practices
JavaScript
615
star
11

native-testing-library

🐳 Simple and complete React Native testing utilities that encourage good testing practices.
JavaScript
515
star
12

testing-library-docs

docs site for @testing-library/*
JavaScript
449
star
13

jest-native

πŸ¦… Custom jest matchers to test the state of React Native
TypeScript
436
star
14

eslint-plugin-jest-dom

eslint rules for use with jest-dom
JavaScript
360
star
15

pptr-testing-library

puppeteer + dom-testing-library = πŸ’–
TypeScript
283
star
16

playwright-testing-library

πŸ” Find elements in Playwright with queries from Testing Library
TypeScript
248
star
17

testing-library-recorder-extension

Testing Library Extension for Chrome DevTools Recorder
TypeScript
144
star
18

preact-testing-library

Simple and complete Preact DOM testing utilities that encourage good testing practices.
JavaScript
139
star
19

which-query

🦩 Which query should I use?
CSS
124
star
20

testcafe-testing-library

πŸ‚ Simple and complete custom Selectors for Testcafe that encourage good testing practices.
TypeScript
71
star
21

preact-hooks-testing-library

Simple and complete Preact hooks testing utilities that encourage good testing practices.
TypeScript
56
star
22

jasmine-dom

πŸ¦₯ Custom Jasmine matchers to test the state of the DOM
JavaScript
45
star
23

nightwatch-testing-library

πŸ¦‡Simple and complete custom queries for Nightwatch that encourage good testing practices.
JavaScript
31
star
24

dom-testing-library-template

Template repository for bug reports to @testing-library/dom, @testing-library/react, and @testing-library/jest-dom
JavaScript
17
star
25

webdriverio-testing-library

πŸ•·οΈ Simple and complete WebdriverIO DOM testing utilities that encourage good testing practices.
TypeScript
16
star
26

native-testing-library-docs

🐳 Docs site for native-testing-library
JavaScript
16
star
27

react-testing-library-help

Fork this repo to reproduce your issue
HTML
12
star
28

web-testing-library

πŸ™ Experimental Web testing utilities that encourage good testing practices.
JavaScript
3
star