testing-library / web-testing-library

🐙 Experimental Web testing utilities that encourage good testing practices.
https://testing-library.com/dom
MIT License
7 stars 3 forks source link
javascript testing

Web Testing Library

octopus

Simple and complete Web testing utilities that encourage good testing practices.

[**Read the docs**](https://testing-library.com/web) | [Edit the docs](https://github.com/testing-library/testing-library-docs)

Build Status Code Coverage version downloads MIT License All Contributors PRs Welcome Code of Conduct Discord

Watch on GitHub Star on GitHub Tweet

TestingJavaScript.com Learn the smart, efficient way to test any JavaScript application.

Table of Contents

The Problem

You want to write maintainable tests for the Web Platform or React Native. 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 Web Testing Library is a very light-weight solution for testing code that runs on the Web Platform (a browser, Node.js, Deno etc) or React Native. 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 and should be installed as one of your project's devDependencies:

npm install --save-dev @testing-library/web

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 code is used on the Web Platform or React Native.

Utilities are included in this project based on the following guiding principles:

  1. They should be usable on both the Web Platform and React Native
  2. It should be generally useful for testing the application 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 environment, but in general, utilities should encourage tests that use the application 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 wonderful people (emoji key):

Augustin Le Fèvre
Augustin Le Fèvre

🤔
Nick McCurdy
Nick McCurdy

🤔
Jacob M-G Evans
Jacob M-G Evans

🤔
Sebastian Silbermann
Sebastian Silbermann

💻 🤔

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

LICENSE

MIT