@testing-library/jest-dom version: ^4.2.4@testing-library/react version: ^9.4.0node version: 10.13.0npm (or yarn) version: 6.4.1 (npm)https://github.com/tom-sherman/jest-dom-nottobeindocument-bug
Specifically https://github.com/tom-sherman/jest-dom-nottobeindocument-bug/blob/master/src/App.test.js#L8
expect(linkElement).not.toBeInTheDocument();
Added in a .not modifier before a .toBeInTheDocument call.
Test failed when it should have passed
Run npm t in this repo https://github.com/tom-sherman/jest-dom-nottobeindocument-bug
I should be able to use .not modifiers on all jest-dom matchers.
Oh I done goofed here...
I thought that the .not.toBeInTheDocument wasn't working correctly but in actual fact it was getByText thowing an error which is expected behaviour.
I can rewrite the test (https://github.com/tom-sherman/jest-dom-nottobeindocument-bug/commit/eca61346d83bec2a1d0212b916bc9a8852dcf6e9) to assert that this call throws.
@tom-sherman - You may want to use queryByText instead of getByText. This way you don't need to check for toThrow.
Most helpful comment
@tom-sherman - You may want to use
queryByTextinstead ofgetByText. This way you don't need to check fortoThrow.