Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactCompositeComponent: injectEnvironment() can only be called once. #1

Closed
clozr opened this issue Oct 7, 2016 · 6 comments
Closed

Comments

@clozr
Copy link

clozr commented Oct 7, 2016

I encountered this error when using react-test-renderer.
Any idea how it can be fixed?

@clozr
Copy link
Author

clozr commented Oct 10, 2016

I figured that your package is set to use enzyme instead of react-test-renderer.

@clozr clozr closed this as completed Oct 10, 2016
@doanndd
Copy link
Member

doanndd commented Oct 11, 2016

FYI, I used react-native-mock with react-addons-test-utils from file env.js. If you want to use with react-test-renderer, you can add this code jest.mock('react-addons-test-utils'); to env.js.

More about this error, you can find in jestjs/jest#1353

Thank you.

@clozr
Copy link
Author

clozr commented Oct 14, 2016

You are using locally cached version of react-native-mock, which doesn't work with latest react-native. I changed the mock in env.js
jest.setMock('react-native', require('react-native-mock/src/react-native'));

Which makes it work.

@doanndd
Copy link
Member

doanndd commented Oct 17, 2016

I updated to latest react-native-mock version. You should rerun npm i react-native-babel-jest.
Thanks!

@clozr
Copy link
Author

clozr commented Oct 21, 2016

Cool Thanks!
I think in your examples you should include an example of snapshot testing using enzyme-to-json. Someone looking to use snapshot testing will know that they don't need react-test-renderer.

@doanndd
Copy link
Member

doanndd commented Oct 24, 2016

Thank you,
I'm doing it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant