-
Notifications
You must be signed in to change notification settings - Fork 755
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
Can't run unit tests with Jest #245
Comments
Try:
|
@dominictracey your solution works fine when putting the mock in each test file. Is there any way to put it in a single place or do I have to put it in every test file I create? |
@henninghall I guess you can apply same workaround as for react-native-i18n. Basically create folder
|
@mauron85 I dont understand how that is a valid mock. I still get the error. TypeError: Sound.setCategory is not a function which makes sense. How do I mock this package correctly in |
If mocked it like:
and the check for function calls in my tests like
which seems to work for me. Maybe someone else finds it useful! |
yeah this same error am also faced 2 hrs ago im fixed like: class Sound {} export default Sound; then save and run your project the error will solve |
Try this; jest.mock('react-native-sound', () => ({ |
While running a most simple unit test I get
TypeError: Cannot read property 'IsAndroid' of undefined
as in issue #36 . However, building and running the app works perfectly fine.Mocking
react-native-sound
viajest.mock('react-native-sound');
doesn't help.The test fails in line
import myComponentWithANestedSubComponentWhichUsesRNSound from './';
of the following code snippet:The text was updated successfully, but these errors were encountered: