Skip to content

Please provide an option to remove the matching of findBy queries by the prefer-explicit-assert rule #449

@julienw

Description

@julienw

What rule do you want to change?

prefer-explicit-assert

Does this change cause the rule to produce more or fewer warnings?

Fewer warnings

How will the change be implemented?

An option matchFindByQueries will be added, true by default.
When it's set to false the rule won't match these queries.

Example code

await findByText(/no profile/i);

How does the current rule affect the code?

The current rule will report an error for such code, but I'd like to be able to exempt it easily.

How will the new rule affect the code?

When the new option is set to false, this code won't be flagged.
When the new option is absent or set to true the code will still be flagged as it is now, so it wouldn't be a breaking change.

Anything else?

My 2 cents: it's common I use findBy assertions in my test code, not to assert that they're here, but rather to ensure we're waiting for something to be displayed before moving forward, so that the test isn't flaky. Therefore adding expect calls in these cases brings distractions :/

References: #409 #421

Do you want to submit a pull request to change the rule?

Yes

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions