-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Labels
enhancementNew feature or requestNew feature or requestnew ruleNew rule to be included in the pluginNew rule to be included in the pluginpinnedPinned for different reasons. Issues with this label won't be flagged as stale by stalebotPinned for different reasons. Issues with this label won't be flagged as stale by stalebot
Description
We could have a new rule that reports waitFor
in cases where waitForElementToBeRemoved
could be used. Could be named prefer-waiting-for-disappearance
or something similar.
From the implementational side, it'd probably make sense to look for RTL queries inside waitFor
and some specific matchers, such as .not.toBeInTheDocument()
, .toBeFalsy()
, etc.
// BAD:
await waitFor(() =>
expect(screen.queryByText("Loading")).not.toBeInTheDocument(),
)
// GOOD
await waitForElementToBeRemoved(() => screen.queryByText("Loading"))
I am also curious about the fact that if this rule is enabled, it doesn't make too much sense to have query*
queries in waitFor
, even when waiting for appearance. Hence, the rule could either report by default or have an option to report this case:
await waitFor(() => expect(screen.queryByText("Loading")).toBeInTheDocument())
WDYT?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestnew ruleNew rule to be included in the pluginNew rule to be included in the pluginpinnedPinned for different reasons. Issues with this label won't be flagged as stale by stalebotPinned for different reasons. Issues with this label won't be flagged as stale by stalebot