Testing · Junior · Question 47 of 78
How do you check that an element is NOT on the page?
- ✓Correct answer:
expect(screen.queryByText("Error")).not.toBeInTheDocument() - 2
expect(screen.getByText("Error")).toBeNull() - 3
expect(screen.findByText("Error")).toBeFalsy()
Explanation
getBy would throw before the assertion runs, and findBy returns a promise, which is always truthy.