jest-dom version: 1.10.0node version: 10.5.0npm (or yarn) version: 6.2.0// downshift/src/__tests__/portal-support.js
const {getByTestId, queryByTestId} = render(
<MyPortalAutocomplete />,
)
expect(queryByTestId('menu')).not.toBeInTheDocument()
getByTestId('button').click()
expect(getByTestId('menu')).toBeInTheDocument()
Tried replacing toBeInDOM with any of the new suggested ways (toBeInTheDocument/ toContainElement )
Both throws an error then the element is null
↑ See relevant code or the Downshift repo https://github.com/paypal/downshift/blob/master/src/__tests__/portal-support.js#L57-L60
As far as I can tell there is no way to replace the current usage of toBeInTheDOM with the other functions. But I might be missing something?
I think they should accept falsy (or at least null) values and just return false if that's the case
See https://github.com/gnapse/jest-dom/issues/34
The recommended approach for testing the existence of elements retrieved via queryBy* is to use toBeNull or toBeTruthy (or even better, toBeInstanceOf(HTMLElement)).
Ah I see, I did read through that thread but don't know how i missed that! 😅 It might be a good idea to add that to the readme as well imo
Thanks!
@alexandernanberg you're right. I just updated the README section about this deprecated matcher to be more clear about why this was done and what the alternatives are. Thanks for the tip.
:tada: This issue has been resolved in version 1.11.0 :tada:
The release is available on:
npm package (@latest dist-tag)Your semantic-release bot :package::rocket: