-
-
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
React Native, Invariant Violation: Native module cannot be null. #6382
Comments
How do you mock OneSignal? Can you provide a minimal repro? |
@thymikee on the test file:
|
Oh, you need to mock the jest.mock('react-native-onesignal', () => {
return {
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
inFocusDisplaying: jest.fn()
}
}) should do the trick |
@thymikee wow, i'm so stupid. thanks for this! |
Hi, I'm a having an issue while running my app "Invariant Violation: Native module cannot be null" Can someone please help for that |
+1 @Pallavisoba |
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. |
🐛 Bug Report
hey, hi! i have a similar issue (i think) here: #2208, but this issue is quite old, and i have followed the solutions there, but none worked for me.
at first, i encountered this error for running
jest
:so i went ahead and added
react-native-onesignal
topackage.json
as such:so that solved my problem. but here comes another problem:
i tried mocking
OneSignal
, but this is what happens when I do that:To Reproduce
Steps to reproduce the behavior:
Expected behavior
test passes, writes a snapshot
The text was updated successfully, but these errors were encountered: