Skip to content

Jest Native Events #8

@sam-n-johnston

Description

@sam-n-johnston

This package works great and thanks a lot for that!

The problem I have is when I try to run tests with Jest on my code. When I run the tests, I get the following error message:

Invariant Violation: Native module cannot be null.

      at invariant (node_modules\fbjs\lib\invariant.js:38:15)
      at new NativeEventEmitter (node_modules\react-native\Libraries\EventEmitter\NativeEventEmitter.js:32:1)
      at Object.<anonymous> (node_modules\@remobile\react-native-file-transfer\libs\FileTransfer.js:29:63)
      at Object.<anonymous> (node_modules\@remobile\react-native-file-transfer\index.js:2:20)

The line in my code that is the culprit is: import FileTransfer from '@remobile/react-native-file-transfer'
I've tried mocking the the module with Jest, but this does not fix the error.

The problem is caused by line 29 in FileTransfer.js: var EventEmitter = Platform.OS==="android"?DeviceEventEmitter:new NativeEventEmitter(NativeModules.FileTransfer);

Can anyone help me with this error?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions