launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
85 stars 68 forks source link

Mock provider #51

Closed eturino closed 3 years ago

eturino commented 3 years ago

Requirements

Related issues

30

Describe the solution you've provided

On one hand, the context is exported now directly on the index so we can use it without having to import from nested imports, which causes issues in some setups.

On the other, I've added a MockProvider that can be used for testing, mock-only mode, etc. The useFlags() hook and consumers will work as usual and they will always receive the flags object passed to MockProvider.

Describe alternatives you've considered

they are discussed in #30

yusinto commented 3 years ago

Thanks for the PR @eturino. We are working towards releasing a jest mock very soon. We are currently in the testing stage of this package so we can't guarantee an ETA just yet. This package will support LaunchDarkly flags in a jest environment so an SDK MockProvider component should no longer be required.

Separately the storybook-addon-launchdarkly package is also in development and should follow after the jest package. Again, we don't have an ETA just yet unfortunately.

We're going to close this PR since we're taking a different approach. You're free to continue using this change on your fork in the meantime.

yusinto commented 3 years ago

@eturino thank you for your patience. We have just published jest-launchdarkly-mock which you can use with jest to test launchdarkly react components.