Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

New rule: force waitForElementToBeRemoved when waitFor is used to wait for disappearance #411

Open
Labels
enhancementNew feature or request new ruleNew rule to be included in the plugin pinnedPinned for different reasons. Issues with this label won't be flagged as stale by stalebot
@zaicevas

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

No one assigned

    Labels

    enhancementNew feature or request new ruleNew rule to be included in the plugin pinnedPinned for different reasons. Issues with this label won't be flagged as stale by stalebot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /