-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Using moduleNameMapper to mock out react native static image resources fails if module name is a path #665
Comments
@frantic @martinbigio did we change how we do relative images in react-native? |
no, we didn't... |
Maybe try Automatic Mocking. @threesquared /image
└── index.js within /image/index.js within component: BTW, moduleNameMapper (without empty mock index.js) worked for me when there was no testPathDirs. |
This should work using |
Has anyone successfully mocked out a React Native "../images/abc.png" require using moduleNameMapper? It looks like the IS_PATH_BASED_MODULE_NAME regex in HasteModuleLoader._getNormalizedModuleID() causes an attempt to resolve relative requires via _resolveModuleName() and _resolveNodeModule() and the latter throws the error mentioned above. |
Note that I have a fix (with updated test case, npm test passing) here: jonestheguitar@05a1456 |
Currently working on a fix but it breaks some internals. |
This'll be fixed in the next release! Thanks @jonesdar for helping to troubleshoot it. See b01ab18 |
0.10.0 has been released with a fix for this :) |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am using the following to mock out react native static images:
This works when the image is
import DeleteIcon from 'delete-icon.png';
but not if it is a pathimport DeleteIcon from '../images/delete-icon.png';
the stacktrace is below.The text was updated successfully, but these errors were encountered: