"It looks like you called mount()
without a global document being loaded." with Enzyme and React Native
#1501
Closed
2 of 4 tasks
Labels
Current behavior
Testing a
mount()
returns this error.So I started testing using
react-test-renderer
(still do for snapshots).Then wanted to test a fully rendered component post
componentDidMount()
(as there is a fetch in there that populates the view) and see how many item rendered. I therefore wanted to usemount()
.I installed
Enzyme
, then got the adapter for my version of React, then gotreact-dom
as it seems like it's needed as dependency, then gotreact-native-mock
as it's recommended.Then realised that
react-native-mock
wasn't working with my version ofreact-native
, so I used the @jonny/react-native-mock.I also installed then uninstalled
react-addons-test-utils
as it is now deprecated.In my
setupTests
file which runs before the tests, I do:Expected behavior
Would love to have that react native component mounted =)
Full example
Component:
and tests:
The
mount
returns: It looks like you calledmount()
without a global document being loaded.The
shallow
works fine.Your environment
API
Version
Adapter
The text was updated successfully, but these errors were encountered: