Flipper: Warning running jest tests

Created on 15 Jul 2020  路  2Comments  路  Source: facebook/flipper

馃悰 Bug Report

When running tests using jest, the following warning appears:

yarn run v1.22.4
$ jest test
  console.warn node_modules/redux-flipper/node_modules/react-native-flipper/index.js:158
    The native module for Flipper seems unavailable. Please verify that `react-native-flipper` is installed as yarn dependency to your project and, for iOS, that `pod install` is run in the `ios` directory.

To Reproduce

Run jest tests with

 if (__DEV__) {
     const createDebugger = require('redux-flipper').default
     middlewares.push(createDebugger())
 }

Environment

"react": "16.13.1",
"react-native": "0.63.0",
"react-native-flipper": "^0.50.0",

Most helpful comment

Hard to give any specific pointers without reproduction, but there is little pointing enabling the Flipper devtools in Jest tests. Typically you would only run the initialization code only in the entry point of your application, but not run jest tests directly against your entry point. If your tests directly or indirectly reference your applications' entry point, there is probably too much in there.

I'd recommend to clean that up a bit if needed, but as work around you could also explicitly check if you are running unit test: if (__DEV__ && !process.env.JEST_WORKER_ID) {

All 2 comments

Hard to give any specific pointers without reproduction, but there is little pointing enabling the Flipper devtools in Jest tests. Typically you would only run the initialization code only in the entry point of your application, but not run jest tests directly against your entry point. If your tests directly or indirectly reference your applications' entry point, there is probably too much in there.

I'd recommend to clean that up a bit if needed, but as work around you could also explicitly check if you are running unit test: if (__DEV__ && !process.env.JEST_WORKER_ID) {

Thank you @mweststrate, I needed to add the middleware to the store, hence the warning.
Also my issue is more related to the extension redux-flipperrather than flipper in itself, my bad.
!process.env.JEST_WORKER_ID does the trick, thanks !

Was this page helpful?
0 / 5 - 0 ratings