-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
How to test FlashMessage and show message using the react native testing library #165
Comments
I never had the opportunity to do that on my own, but some people relate in other issues: I guess that you need to do something with |
I solved my issue by mocking the showMessage and other functions I was using from the library, using Jest and I also had to mock FlashMessage component from react-native-flash-message library and then my tests were passing. I wrote the tests using testing-library/react-native. |
Just for reference how to make a basic mock, that worked for me: jest.mock('react-native-flash-message', () => ({
hideMessage: () => jest.fn(),
showMessage: () => jest.fn(),
__esModule: true,
default: jest.fn().mockReturnValue(() => <></>),
})); |
Hello @lucasferreira can you please reopen this issue? I'm facing the same problem, I've got the two functions inside the showMessage that inst covered: this is my jest.setup:
this is my component:
this is my test file:
this is the result of the running tests: I've tried to do a spyOn but I'm getting this error:
@Lois-Varghese @moiseshilario any idea how to do it? Thanks |
Reopened @rodrigodiasf1984, But I can't help too much here, never done this jest kind of tests in RN. |
"@testing-library/react-native": "^7.2.0",
In the snapshot test I get Flash Message as an invalid element
The text was updated successfully, but these errors were encountered: