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

Test fail with provider in react-native #2137

Closed
1 task done
salarmiirzaeie opened this issue Feb 28, 2024 · 3 comments
Closed
1 task done

Test fail with provider in react-native #2137

salarmiirzaeie opened this issue Feb 28, 2024 · 3 comments

Comments

@salarmiirzaeie
Copy link

What version of React, ReactDOM/React Native, Redux, and React Redux are you using?

  • React: 18.2.0
  • ReactDOM/React Native: 0.73.4
  • Redux:
  • React Redux:9.1.0

What is the current behavior?

When we was trying test components using jest and redux in react-native, it said "SyntaxError: Cannot use import statemen outside a module" where we used Provider from react-redux in version 9.1.0 but in react-redux version 8.1.3 it was passed in jest

What is the expected behavior?

It should pass in version 9.1.0 like other version like v 8.13

Which browser and OS are affected by this issue?

No response

Did this work in previous versions of React Redux?

  • Yes
@markerikson
Copy link
Contributor

We updated React-Redux's packaging in v9, and it should be using ESM modules by default. Our tests show it should work with Jest. If you have a specific issue, please provide a repo that shows this error happening so we can investigate.

@salarmiirzaeie
Copy link
Author

@timdorr
Copy link
Member

timdorr commented Mar 1, 2024

You don't have babel-jest hooked up correctly. Add this to your jest.config.js:

"transform": {
  "\\.[jt]sx?$": "babel-jest"
},

@timdorr timdorr closed this as completed Mar 1, 2024
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