You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While mocking manually is an option when the library changes the API we always spend time to debug tests until we find out our mock needs an update. I think the best would be if we could do in setupFilesAfterEnv: ['./jest.setup.js'] file the following:
importmixpanelMockfrom'mixpanel-react-native/mock';// or if also support web in our react-native appimportmixpanelMockfrom'mixpanel-browser/mock';jest.mock('mixpanel-react-native',()=>mixpanelMock);
Some libraries go as far as import '@shopify/flash-list/jestSetup' but that limits them to Jest. With the above approach I can use any mocking library. Also, when the library changes API the mock is always up to date.
Since Mixpanel is only "logging" library maybe it would be enough if it works in tests without any token or with some special token when it sends nothing to the Mixpanel server and returns empty collections where needed. WDYT?
I would love to see an importable mixpanel mock to use in unit testing.
My current solution:
From another closed issue:
Suggested Solution:
Something like 'react-native-permissions/mock' but in typescript. Which imports into the
setup.tsx
file for jest like so:The text was updated successfully, but these errors were encountered: