Implementing best practices with Testing Library ESLint plugins
In this section, you will learn how to install and use eslint-plugin-testing-library
and eslint-plugin-jest-dom
. The purpose of these plugins is to audit your test code and help you to write tests that follow the best practices of Document Object Model (DOM) Testing Library and jest-dom
. The plugins work by highlighting areas that can be improved and providing recommendations to refactor your code.
Before installing the plugins, we need to have ESLint installed in our project. ESLint is a tool that statistically analyzes and informs you of problems in your code. You can think of ESLint as having someone look over your shoulder to point out issues you might otherwise take longer to debug on your own. For example, you could create the following function:
const reverseWord = str => str.split('').reverse().join('')
In the preceding code, we have a reverseWord
function that reverses a passed...