Jest: ReferenceError: __DEV__ is not defined

Created on 21 Jul 2016  路  7Comments  路  Source: facebook/jest

i want test some components , but i dont konw how to config the package file , so when i test it, the terminal always display the error message :ReferenceError: DEV is not defined .

Most helpful comment

You can add "globals": {"__DEV__": true}" to your config.

All 7 comments

You can add "globals": {"__DEV__": true}" to your config.

@cpojer What about global function like fbq which is Pixel code. It says ReferenceError: fbq is not defined

@codemilli Did you find an answer for this?

use setupFiles

@SimenB How? In the docs it says we need to give a path to a .js file, but if the global functions are loaded through a CDN i don't see how i can do that?

I'm using TypeScript and have declared a global type for those functions but jest isn't picking them up

Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Add this code to package.json

{
  "jest": {
   "globals": {
      "__DEV__": true
    }
  }
}
Was this page helpful?
0 / 5 - 0 ratings