-
Notifications
You must be signed in to change notification settings - Fork 62
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
Flow Annotations causing Jest Test to fail. #168
Comments
Can you try using babel-jest? |
@rlepinski I am using it on my project. I am using Flow in all of my code without issue. I only started running into Jest Flow errors when I import Urban Airship. If I remove the Urban Airship import they go away. |
Ok, I have no idea why our plugin would be at fault but I will take a look. If you could provide a sample project that reproduces the issue that would be extremely helpful. |
Here is an example project. Just pull it down, |
Some progress: https://jestjs.io/docs/en/tutorial-react-native#transformignorepatterns-customization
Moves past the error but onto a new one:
|
Ok, was able to run tests by adding a module mock jestjs/jest#2208
|
@cvongrim I think you should be unblocked for now if you add the above. I will look into precompiling the module on publish and possibly providing a default mock for jest. |
Great! Added that and that fixed it. I have been trying to figure this out all day. Thanks for looking into it. |
Running into this problem as well, added the above, however when the tests are run, I'll receive a "Cannot read property 'setUserNotificationsEnabled' of undefined Any chance this has something to do with the jest.mock? |
@nelsonchen5 This looks to be a different issue than what I had. I didn't have a problem with UrbanAirship. UrbanAirship is imported right? Depending on your test, you might need to mock UrbanAirship. Something like the following.
|
@cvongrim Hi, thanks for the response. I tried mocking it and it doesn't seem to recognize UrbanAirship for some reason |
@nelsonchen5 This issue is unrelated to the original issue. Please open a new issue with more details. We will probably need a project that reproduces the issue to know your exact issue. Most likely the module is not installed properly (npm install) or you are missing an include somewhere. |
Preliminary Info
What Urban Airship dependencies are you using?
urbanairship-react-native: 2.1.3
react-native: 0.57.5
What are the versions of any relevant development tools you are using?
n/a
Report
What unexpected behavior are you seeing?
When running Jest, Urban Airship throws an error due to flow type annotations.
What is the expected behavior?
To be able to continue running my existing Jest Test.
I assume something needs to be added to strip out the Flow annotations when Jest is ran. I would assume this could be a common issue since Jest comes with React Native as the default Testing library.
What are the steps to reproduce the unexpected behavior?
Run a Jest Test on any component that imports urbanairship-react-native.
Do you have logging for the issue?
No
The text was updated successfully, but these errors were encountered: