-
Notifications
You must be signed in to change notification settings - Fork 232
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
Jest: Invariant Violation: new NativeEventEmitter()
requires a non-null argument.
#367
Comments
+1 |
#72 |
The suggested solution didn't work for me. While this error appears to come from
|
i seem to be getting another error after doing this? i'm currently trying to mock deviceInfo module like so: jest.mock('react-native-device-info', () => ({
...jest.requireActual('react-native-device-info'),
getBuildNumber: jest.fn(() => 99),
})); i got this error : Invariant Violation:
|
This might also be a solution: react-native-device-info/react-native-device-info#1360 (comment) |
this helped a lot.=, Thanks man :) |
please where do I find this setup file? as all the answers seem vague |
@AdamuAbba if you have Jest installed in your project you will find this file in the root of your project. The name of the file is |
OMG, this is the best reply so far, so direct and straight to the point. thanks, you're a lifesaver 🔥 |
@AdamuAbba I get |
@Balthazar33 did you try importing jest like so at the top of your import {jest} from '@jest/globals' in an ideal environment, this should not be necessary tho for global modules ..... i think. |
after adding the above line I am getting this error : TypeError: _reactNative.NativeEventEmitter is not a constructor |
jest.setup.json file doesn't exist |
You have to create it
El El mar, 27 jun 2023 a las 11:35, TomJerry56 ***@***.***>
escribió:
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
jest.setup.json file doesn't exist
—
Reply to this email directly, view it on GitHub
<#367 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALKLCYPGUURQLCEGIEBDBQ3XNKSN7ANCNFSM5FQWR2BQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
*Nadine Thêry*
NadineThery.com | Linkedin <https://www.linkedin.com/in/nadinethery/> |
Twitter <http://www.twitter.com/nanythery> |
|
getting same error, Do I need add any other changes in tsconfig related to jest.setup.js? |
|
these two lines in 'jest.setup.js' fixed the issue for the same error in react-native-device-info
maybe it's a similar issue |
Great, this line wasn't mandatory on my case, but helped me to identify the correct problem, because show the real problem. Thank you very much! |
The following error will be reported if jest is not configured
So maybe we should configure jest manually, like:
This allows the unit tests to pass with flying colors
repo here:
https://github.com/shensven/ReadHubn/tree/5806faf354fbd178827aff9985efe4dea906c24d
test here:
https://github.com/shensven/ReadHubn/runs/3824410010?check_suite_focus=true
The text was updated successfully, but these errors were encountered: