posthog-js-lite icon indicating copy to clipboard operation
posthog-js-lite copied to clipboard

React Native app tested with jest fails with: PostHog: No storage available. Please install expo-filesystem or react-native-async-storage OR implement a custom storage provider.

Open itsramiel opened this issue 1 year ago • 1 comments

Bug description

posthog-react-native fails when tested with jest. This was an issue before, but seems to have regressed

How to reproduce

  1. git clone https://github.com/itsramiel/posthog-repro
  2. cd posthog-repor
  3. yarn
  4. yarn test

Related sub-libraries

  • [ ] All of them
  • [ ] posthog-web
  • [ ] posthog-node
  • [x] posthog-react-native

itsramiel avatar May 13 '24 08:05 itsramiel

@itsramiel If you are using the RN SDK v3, you can just set eg persistence to memory or set your custom customStorage when in testing mode, for example, you can check the __DEV__ or something else and set those properties during the RN SDK init. https://posthog.com/docs/libraries/react-native#configuration-options

Does that help?

marandaneto avatar May 14 '24 13:05 marandaneto

@itsramiel did you try this out?

marandaneto avatar May 21 '24 09:05 marandaneto

@itsramiel did you try this out?

Oops forgot to reply. Yes that was my workaround anyway since it was already mentioned in the previous issue, but I thought it was a regression since it was handled internally after the creation of that issue.

If that's the solution going forward, then alright

itsramiel avatar May 21 '24 09:05 itsramiel

Gotcha, yes that is the workaround until those libraries provide the implementation of the missing platforms.

marandaneto avatar May 21 '24 11:05 marandaneto