-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Testing React Native components with images #253
Comments
@rlau1115 looks like React Native create a map of images when you start the local server:
Kiling the current server and running it again should solve your problem. |
Same issue here. @pablolmiranda which server do you mean? Enzyme runs with |
@Purii Did you ever figure it out? I'm running with |
Hey Guys, I had this problem, now I use import mockery from "mockery";
mockery.enable();
mockery.registerMock('../img/gender_male.png', 0)
import React from "react-native";
const {
Text,
TouchableHighlight,
TouchableOpacity,
Image,
} = React
import { shallow } from "enzyme";
// Your Tests Mockery replaces my |
I had the same issue. Was fixed by restarting the server/packager. |
Into this problem too. I tried |
Use mockery. thanks @slamus |
I'm sorry but I really don't understand why people are saying "restart the packager".. The solution of killing it works when you are working on the app and you add a new image and the packager doesn't have any ref to it. So you're in the scope of the app, that's sure. So it seems there is a misunderstanding of the current issue. I have the problem right now on one of my test but all my other ones are working without having to start the RN Packager. I can't use EDIT |
I wrote about this issue a couple of days ago: http://valuemotive.com/2016/08/01/unit-testing-react-native-components-with-mocha-and-enzyme/ See "Ignoring Images on React Native Tests". No need for mockery and doesn't produce proptype warnings. There might be couple of other useful tips too :) EDIT: Seems that my previous employer has moved the blog elsewhere. Check my example repo: https://github.com/varmais/react-native-unit-tests and especially https://github.com/varmais/react-native-unit-tests/blob/master/mocha-setup.js#L3-L12 |
You'd need a react native adapter to use enzyme with React Native. Closing this in favor of #1436. |
I'm getting an error when trying to test a component that has an image. Any insight on how to get this test to pass? Or is it a limitation of enzyme?
The text was updated successfully, but these errors were encountered: