react-native-heap icon indicating copy to clipboard operation
react-native-heap copied to clipboard

Jest mocking instructions

Open tomgreco opened this issue 1 year ago • 1 comments

How to mock this library to work with jest tests?

Without creating any mock and running jest tests after installing this library I get

/node_modules/@heap/react-native-heap/dist/js/Heap.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { NativeModules } from 'react-native';
SyntaxError: Cannot use import statement outside a module```

tomgreco avatar Mar 28 '23 02:03 tomgreco

I mock it like this in my jest setup file: jest.mock('@heap/react-native-heap', () => ({ withReactNavigationAutotrack: jest.fn() }));

Dmitry-GH avatar Aug 28 '23 08:08 Dmitry-GH