Skip to content

Cannot jest.mock('react-instantsearch') since v4.90.0 #6916

@jlowcs

Description

@jlowcs

🐛 Current behavior

Since v4.90.0, mocking react-instantsearch results in all the export being undefined.

🔍 Steps to reproduce

jest.mock('react-instantsearch');

import { useInstantSearch } from 'react-instantsearch';

console.log(useInstantSearch); // undefined

This works, but it's not ideal:

jest.mock('react-instantsearch', () => ({
	...jest.requireActual('react-instantsearch'),
	useInstantSearch: jest.fn(),
}));

Live reproduction

N/A

💭 Expected behavior

We should be able to mock 'react-instantsearch' without having to use weird hacks.

Package version

react-instantsearch v4.90.0

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageIssues to be categorized by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions