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

Prevent resetMocks: true from clearing mock implementations #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michaeldfallen
Copy link

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Describe the solution you've provided

If a team uses resetMocks: true in their jest config then the mocked functions of launchdarkly-react-client-sdk will return undefined during test execution.

To allow teams using resetMocks to use this package I have pulled the mock implementations into a setupMocks function that can be called in beforeEach.

I haven't updated the documentation to explain this usecase, I'd value feedback on where / how to do that.

@yusinto
Copy link
Collaborator

yusinto commented Jun 21, 2023

Thank you for submitting this PR. We will review and provide an update soon.

Copy link
Collaborator

@yusinto yusinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. Please also update the readme with instructions on how to use the new setupLDMocks function.

mockWithLDConsumer.mockImplementation(() => (children: any) => children)
mockWithLDProvider.mockImplementation(() => (children: any) => children)
/* eslint-enable @typescript-eslint/no-explicit-any */
export const setupMocks = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with resetLDMocks, can you please rename this to setupLDMocks?

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

Successfully merging this pull request may close these issues.

2 participants