Skip to content

Unnecessary presence checks on findBy queries #743

Closed
@nathanmmiller

Description

@nathanmmiller

Name for new rule

no-find-by-presence

Description of the new rule

The rule should avoid things like expect(await screen.findBy*()).toBeInTheDocument(), because that's functionally the same as await screen.findBy*().

Perhaps this is a new rule (I proposed a name) or maybe it should just be part of the existing find-by rule.

Testing Library feature

await findBy

Testing Library framework(s)

All, presumaly.

What category of rule is this?

Suggests an alternate way of doing something

Optional: other category of rule

No response

Code examples

expect(await screen.findByRole("button")).toBeInTheDocument();
expect(await screen.findByText("hello")).toBeDefined();
expect(await screen.findByLabel("zoop!")).toBeTruthy();

Anything else?

I am happy to contribute this rule - but if so, it may take me a month or two to do so, as things are busy. Please let me know if you'd like me to contribute or not.

Do you want to submit a pull request to make the new rule?

Yes

Metadata

Metadata

Assignees

Labels

new ruleNew rule to be included in the pluginreleased

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions