File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change 11
11
This rule enforces checking existance of DOM nodes using ` .toBeInTheDocument() ` .
12
12
The rule prefers that matcher over various existance checks such as ` .toHaveLength(1) ` , ` .not.toBeNull() ` and
13
13
similar.
14
+ However it's considered OK to use ` .toHaveLength(value) ` matcher with ` *AllBy* ` queries.
14
15
15
16
Examples of ** incorrect** code for this rule:
16
17
@@ -46,7 +47,7 @@ expect(screen.getByText("foo").length).toBe(1);
46
47
expect (screen .queryByText (" foo" )).toBeInTheDocument ();
47
48
expect (await screen .findByText (" foo" )).toBeInTheDocument ();
48
49
expect (queryByText (" foo" )).toBeInTheDocument ();
49
- expect (wrapper .queryAllByTestId (" foo" )).toBeInTheDocument ( );
50
+ expect (wrapper .queryAllByTestId (" foo" )).toHaveLength ( 1 );
50
51
expect (screen .getAllByLabel (" foo-bar" )).toHaveLength (2 );
51
52
expect (notAQuery (" foo-bar" )).toHaveLength (1 );
52
53
You can’t perform that action at this time.
0 commit comments