@@ -17,17 +17,32 @@ expect(queryByText("foo")).toBeNull();
1717expect (queryByText (" foo" )).not .toBeNull ();
1818expect (queryByText (" foo" )).toBeDefined ();
1919expect (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
2228Examples of ** correct** code for this rule:
2329
2430``` js
2531expect (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
0 commit comments