Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest test __DEV__ is not defined

Basically my issue is that I get an error message, "__DEV__ is not defined" when I run jest. So I have read stackoverflow and other google posts on this. Some have suggested removing my .babelrc, but I actually need that file. Others have suggested adding

"globals": {
  "__DEV__": true
}

To my package.json. I did that as well. I even deleted my node modules folder and re-installed. What should I do? Odd thing is that it was working before, but not now.

like image 546
LemonPie Avatar asked Oct 27 '25 09:10

LemonPie


2 Answers

You can create a jest.config.json file in the root of your react-native project and add this globally as such

{
"jest": {
    "globals": {
    "__DEV__": true
    }
 }
}
like image 187
Pascal Nitcheu Avatar answered Oct 30 '25 01:10

Pascal Nitcheu


Just add globals.DEV = true to your test file or set it in globals part of your jest settings

like image 41
Andreas Köberle Avatar answered Oct 30 '25 01:10

Andreas Köberle