'Jest - toBeNull() and not.toBeNull() return both false
I'm using React, Jest, and React-testing-library. I want to check that some elements are not rendered on my screen.
filterElementsNotPresent.forEach(
({ name }) => {
const nameLabel = queryByText(name);
expect(nameLabel).toBeNull();
So I tried putting the not at the start:
filterElementsNotPresent.forEach(
({ name }) => {
const nameLabel = queryByText(name);
expect(nameLabel).not.toBeNull();
And the result is:
I am really lost. Can someone give me some help with this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


