Skip to content

Latest commit

History

History
179 lines (137 loc) 路 23.2 KB

README.md

File metadata and controls

179 lines (137 loc) 路 23.2 KB

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 dom-testing-library

Docs

Implementations

This library was not built to be used on its own. The original implementation of these utilities was in the react-testing-library.

Implementations include:

Other Solutions

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

馃捇 馃摉 馃殗 鈿狅笍
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

馃摝

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

LICENSE

MIT