Skip to content

Feature request: convert no-get-by-for-checking-element-not-present to be prefer-appropriate-query-for-expect #90

@benmonro

Description

@benmonro
// reports:
expect(getByText("Foo")).not.toBeInTheDocument() // as it already does
expect(queryByText("Foo")).toBeInTheDocument()

// does not report:
expect(queryByText("Foo")).not.toBeInTheDocument()
expect(getByText("Foo")).toBeInTheDocument()

In addition as discussed below in the comments, the use of get* queries inside of waitForElementToBeRemoved will no longer report an error either in a callback or directly as a parameter.

  //does not report:
  await waitForElementToBeRemoved(screen.getByTitle("Loading..."));
  await waitForElementToBeRemoved(() => screen.getByTitle("Loading..."));

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingnew 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