Repository navigation
fix: ignore getBy inside of within for prefer-presence-queries on absence queries - #716
Conversation
Belco90
left a comment
There was a problem hiding this comment.
Hi @nathanmmiller! Thanks for your PR. I left a comment asking for more tests, since I think your implementation is not covering all cases as expected.
| expect(submitButton).not.toBeInTheDocument() | ||
| `, | ||
| `// checking absence on getBy* inside a within with queryBy* outside the within | ||
| expect(within(screen.getByRole("button")).queryByText("Hello")).not.toBeInTheDocument() |
There was a problem hiding this comment.
Could you add another test to check that chained queries from within are reported as expected tho?
expect(within(screen.getByRole("button")).getByText("Hello")).not.toBeInTheDocument()The example above should be reported, but I don't think it will be by your implementation.
There was a problem hiding this comment.
Good call. I think maybe I need to rethink the way I am handling this - it's not sufficient to say "ignore everything inside a within." Lemme rethink and re-PR.
There was a problem hiding this comment.
Actually I think this does correctly handle this use case. I've added the unit test as requested and will re-raise the PR - it correctly deals with this exact case.
Checks
Changes
Context
Fixes #518 [Well, partially fixes it.]