score:62

Accepted answer

to disable this warning

add

jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');

or

jest.mock('NativeAnimatedHelp');

to your test file

I'll show you how I do it

I write in package.json file

"jest": {
    "setupFiles": [
      "./mock.js"
    ],

In file mock.js

jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
jest.mock('NativeAnimatedHelp');

score:3

Nothing above wasn't working for me, but eventually I've found solution here:

  1. create jest-setup.js file (in my case in src/tests directory):

src/tests/jest-setup.js:

import 'react-native-gesture-handler/jestSetup';

jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');

jest.mock('react-native-reanimated', () => {
  const Reanimated = require('react-native-reanimated/mock');

  // The mock for `call` immediately calls the callback which is incorrect
  // So we override it with a no-op
  Reanimated.default.call = () => {};

  return Reanimated;
});

  1. Install necessary packages (in my case react-native-reanimated only, but maybe your code will ask you something else):
npm install --save-dev react-native-reanimated
  1. Add one row to jest config in package.json:
  "jest": {
    "setupFiles": [
      "<rootDir>/src/tests/jest-setup.js"
    ]
  },

If your jest-setup.js file located in other directory - change location accordingly.

After these simple steps, the annoying warning has gone. Thanks Spencer Carli and his article by link above.

score:4

You can safely ignore this warning. useNativeDriver is only important when running the code on device.


Related Query

More Query from same tag