software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.01k stars 1.3k forks source link

Jest error Invariant Violation: Native module cannot be null 2.1.0 #1916

Closed Andarius closed 3 years ago

Andarius commented 3 years ago

Description

When running tests with the 2.1.0 version, the following error is raised.

  ● Test suite failed to run

    Invariant Violation: Native module cannot be null.

      at invariant (node_modules/invariant/invariant.js:40:15)
      at new NativeEventEmitter (node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:49:7)
      at Object.<anonymous> (node_modules/react-native-reanimated/lib/ReanimatedEventEmitter.js:4:16)
      at Object.<anonymous> (node_modules/react-native-reanimated/lib/createAnimatedComponent.js:3:1)

Downgrading to 2.0.0 does not raise an error

Expected behavior

No error raised

Actual behavior & steps to reproduce

Run jest with 2.1.0 version

Snack or minimal code example

Package versions

Affected platforms

github-actions[bot] commented 3 years ago

Issue validator

The issue is valid!

piaskowyk commented 3 years ago

Hey @Andarius You should change the path to setUpJestTest() function in your jest-setup.js file to:

require('react-native-reanimated/lib/reanimated2/jestUtils').setUpTests();

We changed the location of this file during the codebase migration to TS, and we forgot to update documentation.

Andarius commented 3 years ago

Thanks @piaskowyk for the quick answer! It works again now.

Daavidaviid commented 3 years ago

Am i the only one getting this message when I run the jest test suites after adding reanimated 2 to my jest setup file :

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 

?