All Projects → testing-library → Eslint Plugin Testing Library

testing-library / Eslint Plugin Testing Library

Licence: mit
ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Eslint Plugin Testing Library

eslint-plugin-ember-best-practices
Static analysis tools for enforcing best practices in Ember
Stars: ✭ 77 (-79.95%)
Mutual labels:  eslint, eslint-plugin, best-practices
Xo
❤️ JavaScript/TypeScript linter (ESLint wrapper) with great defaults
Stars: ✭ 6,277 (+1534.64%)
Mutual labels:  eslint, eslint-plugin, best-practices
Eslint Plugin Ember
An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
Stars: ✭ 240 (-37.5%)
Mutual labels:  eslint, eslint-plugin, best-practices
eslint-config-get-off-my-lawn
A highly opinionated, sharable config of ESLint rules to produce beautiful, readable JavaScript.
Stars: ✭ 44 (-88.54%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin
Enforcing best practices for Effector
Stars: ✭ 69 (-82.03%)
Mutual labels:  eslint, eslint-plugin
standard-packages
List of packages that use `standard`
Stars: ✭ 32 (-91.67%)
Mutual labels:  development, eslint
eslint-plugin-lodash-template
ESLint plugin for John Resig-style micro template, Lodash's template, Underscore's template and EJS.
Stars: ✭ 15 (-96.09%)
Mutual labels:  eslint, eslint-plugin
Guides
A set of rules we use at @icalialabs to build better software
Stars: ✭ 280 (-27.08%)
Mutual labels:  best-practices, development
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.
Stars: ✭ 19 (-95.05%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Functional
ESLint rules to disable mutation and promote fp in JavaScript and TypeScript.
Stars: ✭ 282 (-26.56%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Import
ESLint plugin with rules that help validate proper imports.
Stars: ✭ 3,722 (+869.27%)
Mutual labels:  eslint-plugin, eslint
eslint-plugin-sql
SQL linting rules for ESLint.
Stars: ✭ 56 (-85.42%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin
😎 基于 @lint-md,提供 eslint-plugin,让 lint-md 玩家在 IDE 中得到愉悦的文档编写体验。
Stars: ✭ 22 (-94.27%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin-expect-type
ESLint plugin with $ExpectType, $ExpectError, and $ExpectTypeSnapshot type assertions
Stars: ✭ 27 (-92.97%)
Mutual labels:  eslint, eslint-plugin
Eslint Config Auto
Automatically configure ESLint based on project dependencies
Stars: ✭ 302 (-21.35%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Vue
Official ESLint plugin for Vue.js
Stars: ✭ 3,592 (+835.42%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Proper Arrows
ESLint rules to ensure proper arrow function definitions
Stars: ✭ 271 (-29.43%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Typescript
TypeScript plugin for ESLint
Stars: ✭ 342 (-10.94%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin
autofix some errors reported by eslint rules.
Stars: ✭ 74 (-80.73%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin-decorator-position
ESLint plugin for enforcing decorator position
Stars: ✭ 32 (-91.67%)
Mutual labels:  eslint, eslint-plugin

eslint-plugin-testing-library

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


Build status Package version MIT License
semantic-release PRs Welcome
Watch on Github Star on Github Tweet

All Contributors

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-testing-library:

$ npm install eslint-plugin-testing-library --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-testing-library globally.

Usage

Add testing-library to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["testing-library"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "testing-library/await-async-query": "error",
    "testing-library/no-await-sync-query": "error",
    "testing-library/no-debug": "warn"
  }
}

Shareable configurations

Recommended

This plugin exports a recommended configuration that enforces good Testing Library practices (you can find more info about enabled rules in the Supported Rules section within the Configurations column).

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/recommended"]
}

Frameworks

Starting from the premise that DOM Testing Library is the base for the rest of Testing Library frameworks wrappers, this plugin also exports different configuration for those frameworks that enforces good practices for specific rules that only apply to them (you can find more info about enabled rules in the Supported Rules section within the Configurations column).

Note that frameworks configurations enable their specific rules + recommended rules.

Available frameworks configurations are:

Angular

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/angular"]
}

React

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/react"]
}

Vue

To enable this configuration use the extends property in your .eslintrc config file:

{
  "extends": ["plugin:testing-library/vue"]
}

Supported Rules

Rule Description Configurations Fixable
await-async-query Enforce async queries to have proper await recommended-badge angular-badge react-badge vue-badge
await-async-utils Enforce async utils to be awaited properly recommended-badge angular-badge react-badge vue-badge
await-fire-event Enforce async fire event methods to be awaited vue-badge
consistent-data-testid Ensure data-testid values match a provided regex.
no-await-sync-events Disallow unnecessary await for sync events
no-await-sync-query Disallow unnecessary await for sync queries recommended-badge angular-badge react-badge vue-badge
no-debug Disallow the use of debug angular-badge react-badge vue-badge
no-dom-import Disallow importing from DOM Testing Library angular-badge react-badge vue-badge fixable-badge
no-manual-cleanup Disallow the use of cleanup
no-render-in-setup Disallow the use of render in setup functions
no-wait-for-empty-callback Disallow empty callbacks for waitFor and waitForElementToBeRemoved
no-wait-for-snapshot Ensures no snapshot is generated inside of a waitFor call
prefer-explicit-assert Suggest using explicit assertions rather than just getBy* queries
prefer-find-by Suggest using findBy* methods instead of the waitFor + getBy queries recommended-badge angular-badge react-badge vue-badge fixable-badge
prefer-presence-queries Enforce specific queries when checking element is present or not
prefer-screen-queries Suggest using screen while using queries
prefer-wait-for Use waitFor instead of deprecated wait methods fixable-badge

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Mario Beltrán Alarcón

💻 📖 👀 ⚠️ 🚇 🐛

Thomas Lombart

💻 📖 👀 ⚠️ 🚇

Ben Monro

💻 📖 ⚠️

Nicola Molinari

💻 ⚠️ 📖 👀

Aarón García Hervás

📖

Matej Šnuderl

🤔 📖

Adrià Fontcuberta

💻 ⚠️

Jon Aldinger

📖

Thomas Knickman

💻 📖 ⚠️

Kevin Sullivan

📖

Jakub Jastrzębski

💻 📖 ⚠️

Nikolay Stoynov

📖

marudor

💻 ⚠️

Tim Deschryver

💻 📖 🤔 👀 ⚠️ 🐛 🚇 📦

Tobias Deekens

🐛

Victor Cordova

💻 ⚠️ 🐛

Dmitry Lobanov

💻 ⚠️

Kent C. Dodds

🐛

Gonzalo D'Elia

💻 ⚠️ 📖 👀

Jeff Rifwald

📖

Leandro Lourenci

🐛 💻 ⚠️

Miguel Erja González

🐛

Pavel Pustovalov

🐛

Jacob Parish

🐛 💻 ⚠️

Nick McCurdy

🤔 💻 👀

Stefan Cameron

🐛

Mateus Felix

💻 ⚠️ 📖

Renato Augusto Gama dos Santos

🤔 💻 📖 ⚠️

Josh Kelly

💻

Alessia Bellisario

💻 ⚠️ 📖

Spencer Miskoviak

💻 ⚠️ 📖 🤔

Giorgio Polvara

💻 ⚠️ 📖

Josh David

📖

Michaël De Boey

💻 📦 🚧

Jian Huang

💻 ⚠️ 📖

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].