Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #13041
Closed
Open
Issue created Mar 02, 2023 by Tudor Morar@arhtudormorar

Testing react-redux

Hi! I am using react-redux in one of my npm packages (the package is using react-redux). How would I go about testing my app?

Below is a reference to the same problem:

          I have the same issue with "react-redux".
 • Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    [...]

    Details:

    ***\node_modules\react-redux\es\connect\connect.js:5
    import connectAdvanced from '../components/connectAdvanced';
    ^^^^^^

    SyntaxError: Unexpected token import

      4 | import LoginMethodComponent from './LoginMethodComponent';
      5 | import { startPollUpdateBankIDStatus } from '../../../redux/modules/bankID/userBankIDReducer';
    > 6 | import connect from 'react-redux/es/connect/connect';
        | ^
      7 | import { bindActionCreators } from 'redux';
      8 |
      9 | export class LoginMethodContainer extends React.Component {

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
      at Object.<anonymous> (src/components/user/login/LoginMethodContainer.js:6:1)
      at Object.<anonymous> (src/components/user/login/__tests__/LoginMethodContainer.test.js:3:1)

The temporary fix for now seems to be to specify "transformIgnorePatterns" as mentioned above:

"scripts": {
    ...
    "test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!(react-redux))/\"",
    ...
  },

Originally posted by @jangerhard in https://github.com/facebook/create-react-app/issues/5241#issuecomment-426986623

Assignee
Assign to
Time tracking