So this is probably not a Redux issue per se but since this is a popular project and this just came up with the new update I'm hoping somebody else has run into this and may offer some help. I've been dealing with this exact issue in other projects and was not able to resolve it.
When running unit tests with Jest I'm seeing the following error after upgrading to
react-redux
v9.0.0.
.../node_modules/react-redux/dist/react-redux.react-native.mjs:2
import * as ReactOriginal from "react";
^^^^^^
SyntaxError: Cannot use import statement outside a module
8 | } from 'react';
9 | import { AppState, Linking } from 'react-native';
> 10 | import { useSelector } from 'react-redux';
11 | import {
12 | LinkingOptions,
13 | createNavigationContainerRef,
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
at Object.require (src/navigation/root/RootNavigator.tsx:10:1)
jest.config.js
:
module.exports = {
preset: 'react-native',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'mjs', 'json', 'node'],
transformIgnorePatterns: ['<roodDir>/__mocks__', 'jest-runner'],
setupFiles: [
'<rootDir>/jest.setup.js',
'./node_modules/react-native-gesture-handler/jestSetup.js',
'dotenv/config',
moduleNameMapper: {
'\\.(jpg|jpeg|svg|png)$': '<rootDir>/__mocks__/fileMock.js',
Anybody able to share a working Jest config?
What is the expected behavior?
Expecting Jest unit tests to be able to parse all modules.
Which browser and OS are affected by this issue?
No response
Did this work in previous versions of React Redux?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
No one assigned
Labels
No labels
No labels
Type
No type
Projects
No projects
Milestone
No milestone
Relationships
None yet
Development
No branches or pull requests
Issue actions