launchdarkly / jest-launchdarkly-mock

Easily unit test LaunchDarkly feature flagged components with jest
Apache License 2.0
25 stars 19 forks source link

Does not mock the provider functions #3

Closed greeze closed 2 years ago

greeze commented 3 years ago

The provider functions asyncWithLDProvider and withLDProvider are not mocked, but are exported from 'launchdarkly-react-client-sdk'. One approach might be something along these lines:

jest.mock('launchdarkly-react-client-sdk', () => {
  return {
    ...jest.requireActual('launchdarkly-react-client-sdk'),
    useLDClient: jest.fn(),
    useFlags: jest.fn(),
    withLDConsumer: jest.fn(),
  }
})
leftmostgeek commented 3 years ago

I also Just ran into this issue except I'm using LDProvider is it possible to implement mocks for the providers in this lib?

SHND commented 2 years ago

It seems that this is not still published on npm. Do you know when is it possible to have this on npm?

dv297 commented 2 years ago

@yusinto I'm wondering if #15 was lost during some transition. Not totally sure about the branch set up, but it looks like that PR was merged to master but now this repo only has a main branch, and this change was not published as part of the 1.0.0 release.