dom-testing-library

? Simple and complete DOM testing utilities that encourage good testing practices.

  • Owner: testing-library/dom-testing-library
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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 @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):

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

LICENSE

MIT

Main metrics

Overview
Name With Ownertesting-library/dom-testing-library
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2018-04-06 13:08:11
Pushed At2024-08-01 21:28:49
Last Commit At
Release Count315
Last Release Namev10.4.0 (Posted on )
First Release Namev1.0.0 (Posted on 2018-04-06 07:29:06)
用户参与
Stargazers Count3.3k
Watchers Count31
Fork Count470
Commits Count654
Has Issues Enabled
Issues Count609
Issue Open Count87
Pull Requests Count589
Pull Requests Open Count29
Pull Requests Close Count92
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private