-
Notifications
You must be signed in to change notification settings - Fork 386
ReferenceError: window is not defined #609
Comments
Thanks for opening this issue, could you quickly make a repository with this behaviour? We have RN tests with Jest without problem 🤔 |
there you go @Haroenv I've updated the desc |
This is linked to the JavaScript client, I bet when running tests with Jest, if you are in the node env instead of jsdom this trigger that |
I don't think that's the cause @vvo, since the default is |
Edit: It's not related to newer version of React Native actually,
|
As a workaround you can define You can take example on the if (typeof window !== 'object') {
global.window = global;
global.window.navigator = {};
} https://github.com/expo/jest-expo/blob/master/src/setup.js#L17 |
that's exactly what I did to circumvent the problem but I don't think it's an acceptable long-term solution. I don't think that window should be used for RN code. I don't know what's the community thoughts though, what do you think? Edit: wait, window is defined in the RN env? This makes no sense to me |
Window is defined in RN code for some globals |
I'm closing this one since we have a workaround. Feel free to reopen if you feel this isn't sufficient 😄 |
I'm use this config on my "jest": {
"globals": {
"window": {}
}
} |
could you make a reproducible example @vUdav ? |
Env: react-native + jest (during test run)
Version: 4.2.0 (latest)
Bug: Current behavior
When running
jest
I get the following error:Bug: Expected behavior
Use
global
instead here.How to reproduce
The text was updated successfully, but these errors were encountered: