Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'launchdarkly-react-client-sdk' #77

Open
igor-goldny opened this issue Sep 29, 2024 · 3 comments
Open

Cannot find module 'launchdarkly-react-client-sdk' #77

igor-goldny opened this issue Sep 29, 2024 · 3 comments

Comments

@igor-goldny
Copy link

Describe the bug
When running the mock in my tests I get the following error:

Cannot find module 'launchdarkly-react-client-sdk' from 'node_modules/jest-launchdarkly-mock/dist/index.js'

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.<anonymous> (node_modules/jest-launchdarkly-mock/dist/index.js:7:6)

To reproduce

  1. Setup jest-launchdarkly-mock
  2. Run tests with LD

Expected behavior
package should contain launchdarkly-react-client-sdk dependencies

Logs

coming from here:

jest.mock('launchdarkly-react-client-sdk', function () {
    var camelCaseKeys = jest.requireActual('launchdarkly-react-client-sdk').camelCaseKeys;
    return {
        asyncWithLDProvider: jest.fn(),
        camelCaseKeys: camelCaseKeys,
        LDProvider: jest.fn(),
        useLDClient: jest.fn(),
        useFlags: jest.fn(function () { return ({}); }),
        useLDClientError: jest.fn(),
        withLDConsumer: jest.fn(),
        withLDProvider: jest.fn(),
    };
});

SDK version
"jest-launchdarkly-mock": "^2.1.0"

Language version, developer tools
Node - 20.15.1
Jest - 29.7.0
React - 17

OS/platform
MacOS

@kinyoklion
Copy link
Member

Hello @igor-goldny,

This package does not provide the react SDK. It is a package that is intended to be used against your existing dependency on the react-client-sdk.

It expresses this via a peer dependency. Meaning you have to directly depend on the launchdarkly-react-client-sdk in your project, and if you do not, then there isn't a reason to use this package. (As this is a package for mocking the SDK in tests, and if the SDK is not in use, then there is no need to mock it.)

Thank you,
Ryan

@thoughtworks-tcaceres
Copy link

Guess it doesn't work with the react native sdk then?

@kinyoklion
Copy link
Member

It does not. This package is for the react SDK, which is not the same as the react-native SDK. There is a version in development for react-native.
https://github.com/launchdarkly/js-core/tree/main/packages/tooling/jest

It isn't ready for usage yet though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants