Skip to content

Commit e3eb694

Browse files
authored
Merge branch 'master' into prefer-in-document-recommended
2 parents 6f24739 + c397bd1 commit e3eb694

12 files changed

+1214
-933
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ learn how: http://kcd.im/pull-request
1818
Relevant code or config
1919

2020
```javascript
21+
2122
```
2223

2324
What you did:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Name | 👍 | 🔧 | Description
111111
[prefer-to-have-attribute](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-to-have-attribute.md) | 👍 | 🔧 | prefer toHaveAttribute over checking getAttribute/hasAttribute
112112
[prefer-to-have-style](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-to-have-style.md) | 👍 | 🔧 | prefer toHaveStyle over checking element style
113113
[prefer-to-have-text-content](https://github.com/testing-library/eslint-plugin-jest-dom/blob/master/docs/rules/prefer-to-have-text-content.md) | 👍 | 🔧 | Prefer toHaveTextContent over checking element.textContent
114+
114115
<!-- __END AUTOGENERATED TABLE__ -->
115116

116117
## Issues

docs/rules/prefer-in-document.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,32 @@ expect(queryByText("foo")).toBeNull();
1717
expect(queryByText("foo")).not.toBeNull();
1818
expect(queryByText("foo")).toBeDefined();
1919
expect(queryByText("foo")).not.toBeDefined();
20+
21+
const foo = screen.getByText("foo");
22+
expect(foo).toHaveLength(1);
23+
24+
const bar = screen.queryByText("bar");
25+
expect(bar).toHaveLength(0);
2026
```
2127

2228
Examples of **correct** code for this rule:
2329

2430
```js
2531
expect(screen.queryByText("foo")).toBeInTheDocument();
26-
expect(screen.queryByText("foo")).toBeInTheDocument();
27-
expect(queryByText("foo")).toBeInTheDocument()`;
28-
expect(wrapper.queryAllByTestId('foo')).toBeInTheDocument()`;
29-
expect(screen.getAllByLabel("foo-bar")).toHaveLength(2)`;
30-
expect(notAQuery('foo-bar')).toHaveLength(1)`;
32+
expect(await screen.findByText("foo")).toBeInTheDocument();
33+
expect(queryByText("foo")).toBeInTheDocument();
34+
expect(wrapper.queryAllByTestId("foo")).toBeInTheDocument();
35+
expect(screen.getAllByLabel("foo-bar")).toHaveLength(2);
36+
expect(notAQuery("foo-bar")).toHaveLength(1);
37+
38+
const foo = screen.getAllByText("foo");
39+
expect(foo).toHaveLength(3);
40+
41+
const bar = screen.queryByText("bar");
42+
expect(bar).not.toBeDefined();
43+
44+
const baz = await screen.findByText("baz");
45+
expect(baz).toBeDefined()
3146
```
3247

3348
## When Not To Use It

other/MAINTAINING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ necessary by the git commit messages. With this in mind, **please brush up on
6666

6767
Thank you so much for helping to maintain this project!
6868

69-
[commit]:
70-
https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md
69+
[commit]: https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
"rules": {
6060
"babel/quotes": "off",
6161
"max-lines-per-function": "off",
62-
"testing-library/no-dom-import": "off"
62+
"testing-library/no-dom-import": "off",
63+
"consistent-return": "off"
6364
}
6465
},
6566
"eslintIgnore": [

smoke-test/eslint-remote-tester.config.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,6 @@ module.exports = {
2020
'bundle\\.js',
2121
'react-dom\\.development\\.js',
2222
'\\.min\\.js', // Any *.min.js
23-
24-
// Project specific ignores
25-
'codesandbox-client/packages/app/static/js',
26-
'codesandbox-client/standalone-packages',
27-
'dockunit/platform/assets',
28-
'hyper/bin',
29-
'react-solitaire/lib/index\\.js',
30-
'Khan/perseus/lib',
31-
'glortho/react-keydown/example/public',
32-
'reach/reach-ui/packages/combobox/examples/cities\\.ts',
33-
'reach/reach-ui/website/src/components/cities\\.js',
34-
'reach/reach-ui/website/static/router/static',
35-
'Automattic/wp-calypso/client/components/phone-input/data\\.js',
36-
'test262-main\\.ts',
37-
'sample_vis\\.test\\.mocks\\.ts',
3823
].join('|')})`,
3924

4025
/** Empty array since we are only interested in linter crashes */
@@ -67,7 +52,7 @@ module.exports = {
6752
'plugin:jest-dom/recommended',
6853
],
6954
rules: {
70-
'prefer-in-document': 'error'
55+
'jest-dom/prefer-in-document': 'error'
7156
},
7257
},
7358
};

0 commit comments

Comments
 (0)