launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
79 stars 67 forks source link

fix: 🐛 expose Provider for mocking and testing #234

Closed kodai3 closed 5 months ago

kodai3 commented 6 months ago

Requirements

Related issues

https://github.com/launchdarkly/react-client-sdk/issues/30#issuecomment-1645226153 https://github.com/kodai3/storybook-addon-launchdarkly/issues/10

Describe the solution you've provided

Exported necessary contents to mock for things like storybook to maintain workarounds we were able to do In versions below 3.06

maybe we should add prefix in case people use without intension.

Describe alternatives you've considered

Official storybook addon support was mentioned in the same issue but no update for 3 years. Can I expect for this ?

Additional context

Add any other context about the pull request here.

kodai3 commented 6 months ago

@bnussman-akamai Thank you for your review and the workaround !

@yusinto @louis-launchdarkly @kinyoklion Hi, Can I merge this? Or Do you have other idea for the issue ?

yusinto commented 6 months ago

@kodai3 thanks for submitting the PR. The react context Provider and ReactSdkContext type are designed for internal use only and they are not meant to be exposed for general use. I do see the need to support storybook though and I have created an example on how to mock LaunchDarkly flags in storybook.

We are in process of rewriting the react sdk and we will release an updated version of the jest-launchdarkly-mock which should support storybook. In the meantime, the example aforementioned should work.

kodai3 commented 6 months ago

@yusinto Thank you for taking the time to present the example. It seems that following the method in the example, I can handle like we have addon.

However, it appears that there have been no updates about the storybook support to the community for over three years since this comment, and to be honest, I'm finding it hard to have expectations for the 'updated version of the jest-launchdarkly-mock'. Do you have any plans to publish a roadmap, including the rewriting process?

I've been creating a custom LD addon allows for checking (and manipulating) statuses from a storybook GUI for my team. Since it requires the implementation of a redundant mock context, I'd be still happy if they were exported. However, if there's a clear timeline for the release, I'd be willing to discard my work and look forward to it