Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest mocking instructions #376

Open
tomgreco opened this issue Mar 28, 2023 · 1 comment
Open

Jest mocking instructions #376

tomgreco opened this issue Mar 28, 2023 · 1 comment

Comments

@tomgreco
Copy link

tomgreco commented Mar 28, 2023

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```
@Dmitry-GH
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants