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

react-instantsearch import fails in jest jsdom environment since 7.11.0 #6309

Closed
1 task done
chrisvltn opened this issue Jul 31, 2024 · 1 comment · Fixed by #6310
Closed
1 task done

react-instantsearch import fails in jest jsdom environment since 7.11.0 #6309

chrisvltn opened this issue Jul 31, 2024 · 1 comment · Fixed by #6310
Labels
triage Issues to be categorized by the team

Comments

@chrisvltn
Copy link
Contributor

🐛 Current behavior

After upgrading to [email protected], our tests started to fail with the following error:

SyntaxError: Unexpected token 'export'

When investigating the issue, we found out it was introduced with this change, as now ../widgets is imported instead of ../widgets/index/index, and where ./answers/answers is imported, where preact is imported.

Preact knows about this issue (preactjs/preact#4406), but for now there is no plan on fixing it.

For now, I managed to get around this issue by adding a testEnvironmentOptions.customExportConditions jest configuration to our repository:

testEnvironmentOptions: {
  customExportConditions: ['require'],
}

🔍 Steps to reproduce

  1. Clone https://github.com/chrisvltn/algolia-jsdom-issue
  2. Run npm install
  3. Run npm run test

Live reproduction

https://github.com/chrisvltn/algolia-jsdom-issue

💭 Expected behavior

Tests to pass without runtime error.

Package version

[email protected]

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@chrisvltn chrisvltn added the triage Issues to be categorized by the team label Jul 31, 2024
@Haroenv
Copy link
Contributor

Haroenv commented Aug 1, 2024

Thanks, that change wasn't intentional, the import should have only been changed for the types. I'll revert the change in code and you'll be able to verify that works again in your setup.

See #6310 for the PR and instructions on how to try it out in your setup

Haroenv added a commit that referenced this issue Aug 1, 2024
This avoids side effects or other widgets being imported when only the InstantSearch component is imported.

fixes #6309
@Haroenv Haroenv closed this as completed in 209bb00 Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issues to be categorized by the team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants