Skip to content

Commit c42bae1

Browse files
pierrezimmermannbampierrezimmermannthymikee
authored
docs: add doc on compatibility with eslint-plugin-testing-library (#884)
* docs: add doc on compatibility with eslint-plugin-testing-library * Update website/docs/EslintPLluginTestingLibrary.md * Update website/docs/EslintPLluginTestingLibrary.md Co-authored-by: pierrezimmermann <pierrez@nam.tech> Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
1 parent 8ab46b4 commit c42bae1

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
id: eslint-plugin-testing-library
3+
title: ESLint Plugin Testing Library Compatibility
4+
---
5+
6+
7+
Most of the rules of the [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library) are compatible with this library except the followings:
8+
9+
- [prefer-screen-queries](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md): there is no screen object so this rule shouldn't be used
10+
11+
- [prefer-user-event](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-user-event.md): userEvent requires a dom environement so it is not compatible with this library
12+
13+
Also, some rules have become useless, unless maybe you're using an old version of the library:
14+
15+
- [prefer-wait-for](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-wait-for.md): the wait utility is no longer available
16+
17+
- [no-wait-for-empty-callback](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-empty-callback.md): waitFor callback param is no longer optional
18+
19+
To get the rule [consistent-data-testid](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/consistent-data-testid.md) to work, you need to configure it to check the testID attribute by adding the following in your eslint config file, the `testIdPattern` being whichever pattern you want to enforce:
20+
21+
```javascript
22+
{
23+
"testing-library/consistent-data-testid": [
24+
2,
25+
{
26+
"testIdAttribute": ["testID"],
27+
"testIdPattern": "^TestId(__[A-Z]*)?$"
28+
}
29+
]
30+
}
31+
```

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
'migration-v7',
88
'migration-v2',
99
'how-should-i-query',
10+
'eslint-plugin-testing-library',
1011
],
1112
Examples: ['react-navigation', 'redux-integration'],
1213
},

0 commit comments

Comments
 (0)