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

jest: Test suite failed to run, TypeError: Cannot read property 'bind' of undefined #3114

Closed
Harishn28 opened this Issue Mar 9, 2017 · 27 comments

Comments

Projects
None yet
@Harishn28

Harishn28 commented Mar 9, 2017

we were using jest from unit testing in react-native. It was working well. We just deleted npm and installed it again and then when we tried to run unit test(npm test) we are getting following error and we are not able to run test cases.

The dev dependency in package.json is
"devDependencies": {
"babel-core": "^6.17.0",
"babel-jest": "^18.0.0",
"babel-loader": "^6.2.5",
"babel-plugin-transform-decorators": "^6.13.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2017": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"enzyme": "^2.7.1",
"eslint": "^3.12.1",
"eslint-config-rallycoding": "^3.1.0",
"jest": " * ",
"jest-cli": "18.1.0",
"jest-react-native": "16.0.0",
"react-addons-test-utils": "^15.4.2",
"react-dom": "^15.4.2",
"react-test-renderer": "*"
}

@thymikee

This comment has been minimized.

Show comment
Hide comment
@thymikee

thymikee Mar 9, 2017

Collaborator

I remember having similar issue when using different versions of Jest linked to local copy, which was somehow coupled with testEnvironment config option. Can you try to remove it if present (defaults to jsdom)? That worked for me back then.

Collaborator

thymikee commented Mar 9, 2017

I remember having similar issue when using different versions of Jest linked to local copy, which was somehow coupled with testEnvironment config option. Can you try to remove it if present (defaults to jsdom)? That worked for me back then.

@cpojer

This comment has been minimized.

Show comment
Hide comment
@cpojer

cpojer Mar 9, 2017

Contributor

Why is your Jest dependency empty? You only need one, either jest or jest-cli.

Contributor

cpojer commented Mar 9, 2017

Why is your Jest dependency empty? You only need one, either jest or jest-cli.

@cpojer cpojer closed this Mar 9, 2017

@kentcdodds

This comment has been minimized.

Show comment
Hide comment
@kentcdodds

kentcdodds Mar 9, 2017

Contributor

I just ran into this as well. It appears that when the testEnvironment is set to jest-environment-jsdom, the this._environment.moduleMocker does not have a fn property (either on itself or the prototype). At least that's what I uncovered while looking into the issue. This is not a problem with v18 of Jest.

Contributor

kentcdodds commented Mar 9, 2017

I just ran into this as well. It appears that when the testEnvironment is set to jest-environment-jsdom, the this._environment.moduleMocker does not have a fn property (either on itself or the prototype). At least that's what I uncovered while looking into the issue. This is not a problem with v18 of Jest.

@kentcdodds

This comment has been minimized.

Show comment
Hide comment
@kentcdodds

kentcdodds Mar 9, 2017

Contributor

Note that the jest-environment-node works just fine.

Contributor

kentcdodds commented Mar 9, 2017

Note that the jest-environment-node works just fine.

@cpojer

This comment has been minimized.

Show comment
Hide comment
@cpojer

cpojer Mar 9, 2017

Contributor

Are you sure you have the latest versions of all Jest packages of version 19? This might break if you have some Jest 18 and some Jest 19 packages.

Contributor

cpojer commented Mar 9, 2017

Are you sure you have the latest versions of all Jest packages of version 19? This might break if you have some Jest 18 and some Jest 19 packages.

@kentcdodds

This comment has been minimized.

Show comment
Hide comment
@kentcdodds

kentcdodds Mar 9, 2017

Contributor

I have babel-jest@19.0.0 and jest@19.0.2 in my package.json and this results in having the following packages@version in my `node_modules:

babel-jest@19.0.0
babel-plugin-jest-hoist@19.0.0
babel-preset-jest@19.0.0
jest@19.0.2
jest-changed-files@19.0.2
jest-cli@19.0.2
jest-config@18.1.0
jest-diff@18.1.0
jest-environment-jsdom@18.1.0
jest-environment-node@18.1.0
jest-file-exists@17.0.0
jest-haste-map@18.1.0
jest-jasmine2@18.1.0
jest-matcher-utils@19.0.0
jest-matchers@18.1.0
jest-message-util@19.0.0
jest-mock@18.0.0
jest-regex-util@19.0.0
jest-resolve@18.1.0
jest-resolve-dependencies@19.0.0
jest-runtime@19.0.2
jest-snapshot@18.1.0
jest-util@18.1.0
jest-validate@19.0.2

I'm using the latest version of yarn to install dependencies.

Contributor

kentcdodds commented Mar 9, 2017

I have babel-jest@19.0.0 and jest@19.0.2 in my package.json and this results in having the following packages@version in my `node_modules:

babel-jest@19.0.0
babel-plugin-jest-hoist@19.0.0
babel-preset-jest@19.0.0
jest@19.0.2
jest-changed-files@19.0.2
jest-cli@19.0.2
jest-config@18.1.0
jest-diff@18.1.0
jest-environment-jsdom@18.1.0
jest-environment-node@18.1.0
jest-file-exists@17.0.0
jest-haste-map@18.1.0
jest-jasmine2@18.1.0
jest-matcher-utils@19.0.0
jest-matchers@18.1.0
jest-message-util@19.0.0
jest-mock@18.0.0
jest-regex-util@19.0.0
jest-resolve@18.1.0
jest-resolve-dependencies@19.0.0
jest-runtime@19.0.2
jest-snapshot@18.1.0
jest-util@18.1.0
jest-validate@19.0.2

I'm using the latest version of yarn to install dependencies.

@kentcdodds

This comment has been minimized.

Show comment
Hide comment
@kentcdodds

kentcdodds Mar 9, 2017

Contributor

I'm not sure why this is installing v18 of the jest-environment packages, but it is, and that's the problem. Workaround is to add those to my package.json, but... :-/

Contributor

kentcdodds commented Mar 9, 2017

I'm not sure why this is installing v18 of the jest-environment packages, but it is, and that's the problem. Workaround is to add those to my package.json, but... :-/

@cpojer

This comment has been minimized.

Show comment
Hide comment
@cpojer

cpojer Mar 9, 2017

Contributor

Oh wow, this is not great. Every single one of those packages should be 19.x. Would you mind inspecting the "dependencies" fields in some of those packages and see if they point to 18.x? That may point to an issue with lerna when publishing.

Contributor

cpojer commented Mar 9, 2017

Oh wow, this is not great. Every single one of those packages should be 19.x. Would you mind inspecting the "dependencies" fields in some of those packages and see if they point to 18.x? That may point to an issue with lerna when publishing.

@kentcdodds

This comment has been minimized.

Show comment
Hide comment
@kentcdodds

kentcdodds Mar 9, 2017

Contributor

Weird. I just created a new project with only babel-jest and jest and the versions are all 19.x. So there's probably something else up in my project. Looking.

Contributor

kentcdodds commented Mar 9, 2017

Weird. I just created a new project with only babel-jest and jest and the versions are all 19.x. So there's probably something else up in my project. Looking.

@kentcdodds

This comment has been minimized.

Show comment
Hide comment
@kentcdodds

kentcdodds Mar 9, 2017

Contributor

I just realized why this is happening... Because I'm manually including Jest inside a create-react-app project. Was hoping I could have my cake and eat it too ;-) Looks like I'll have to wait for CRA to update Jest. Thanks!

Contributor

kentcdodds commented Mar 9, 2017

I just realized why this is happening... Because I'm manually including Jest inside a create-react-app project. Was hoping I could have my cake and eat it too ;-) Looks like I'll have to wait for CRA to update Jest. Thanks!

@Harishn28

This comment has been minimized.

Show comment
Hide comment
@Harishn28

Harishn28 Mar 12, 2017

Upgrading jest-cli from from 18 to 19 solved the issue.

Harishn28 commented Mar 12, 2017

Upgrading jest-cli from from 18 to 19 solved the issue.

@Alex1990

This comment has been minimized.

Show comment
Hide comment
@Alex1990

Alex1990 Apr 8, 2017

When I upgrade node from 5.12.0 to 6.10.2, this error is disappeared.

Alex1990 commented Apr 8, 2017

When I upgrade node from 5.12.0 to 6.10.2, this error is disappeared.

@natdm

This comment has been minimized.

Show comment
Hide comment
@natdm

natdm May 12, 2017

I still get this with running a build on circle.

package.json:

{
    "name": "frontend",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "auth0-lock": "^10.14.0",
        "babel-cli": "^6.24.1",
        "babel-jest": "^19.0.0",
        "babel-plugin-syntax-flow": "^6.18.0",
        "jest": "^19.0.2",
        "lodash": "^4.17.4",
        "moment": "^2.18.1",
        "moments": "^0.0.2",
        "proxyquire": "^1.7.11",
        "react": "^15.5.4",
        "react-breadcrumbs": "^1.6.6",
        "react-datetime": "^2.8.9",
        "react-dom": "^15.5.4",
        "react-dropzone": "^3.13.1",
        "react-redux": "^5.0.4",
        "react-router": "^4.1.1",
        "react-router-dom": "^4.1.1",
        "react-router-redux": "^5.0.0-alpha.6",
        "redux": "^3.6.0",
        "redux-devtools": "^3.3.2",
        "redux-form": "^6.6.3",
        "redux-localstorage": "^0.4.1",
        "redux-thunk": "^2.2.0",
        "semantic-ui-react": "^0.68.0",
        "sinon": "^2.2.0",
        "superagent": "^3.5.2"
    },
    "devDependencies": {
        "@kadira/storybook": "^2.21.0",
        "faker": "^4.1.0",
        "flow-bin": "^0.44.2",
        "react-scripts": "0.9.5"
    },
    "scripts": {
        "start": "REACT_APP_URL=http://localhost:3001 react-scripts start",
        "build": "REACT_APP_URL=<REDACTED> react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject",
        "flow": "flow",
        "storybook": "start-storybook -p 9009 -s public",
        "build-storybook": "build-storybook -s public"
    }
}

circle:

machine:
    node:
        version: 6.10.3

test:
    override:
        - CI=true npm test

dependencies:
    override:
        - yarn --ignore-engines

deployment:
    master:
        branch: master
        commands:
            - firebase deploy --token "$FIREBASE_DEPLOY_TOKEN" --non-interactive

CircleCI output:

$ CI=true npm test

> frontend@0.1.0 test /home/ubuntu/<REDACTED>
> react-scripts test --env=jsdom

 FAIL  src/reducers/transactions/reducer.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'bind' of undefined
      
      at Runtime._createRuntimeFor (node_modules/jest-runtime/build/index.js:640:37)
      at handle (node_modules/worker-farm/lib/child/index.js:41:8)
      at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
      at emitTwo (events.js:106:13)
      at process.emit (events.js:191:7)

 FAIL  src/reducers/contacts/reducer.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'bind' of undefined
      
      at Runtime._createRuntimeFor (node_modules/jest-runtime/build/index.js:640:37)
      at handle (node_modules/worker-farm/lib/child/index.js:41:8)
      at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
      at emitTwo (events.js:106:13)
      at process.emit (events.js:191:7)

....

Test Suites: 9 failed, 9 total
Tests:       0 total
Snapshots:   0 total
Time:        11.745s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

CI=true npm test returned exit code 1

natdm commented May 12, 2017

I still get this with running a build on circle.

package.json:

{
    "name": "frontend",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "auth0-lock": "^10.14.0",
        "babel-cli": "^6.24.1",
        "babel-jest": "^19.0.0",
        "babel-plugin-syntax-flow": "^6.18.0",
        "jest": "^19.0.2",
        "lodash": "^4.17.4",
        "moment": "^2.18.1",
        "moments": "^0.0.2",
        "proxyquire": "^1.7.11",
        "react": "^15.5.4",
        "react-breadcrumbs": "^1.6.6",
        "react-datetime": "^2.8.9",
        "react-dom": "^15.5.4",
        "react-dropzone": "^3.13.1",
        "react-redux": "^5.0.4",
        "react-router": "^4.1.1",
        "react-router-dom": "^4.1.1",
        "react-router-redux": "^5.0.0-alpha.6",
        "redux": "^3.6.0",
        "redux-devtools": "^3.3.2",
        "redux-form": "^6.6.3",
        "redux-localstorage": "^0.4.1",
        "redux-thunk": "^2.2.0",
        "semantic-ui-react": "^0.68.0",
        "sinon": "^2.2.0",
        "superagent": "^3.5.2"
    },
    "devDependencies": {
        "@kadira/storybook": "^2.21.0",
        "faker": "^4.1.0",
        "flow-bin": "^0.44.2",
        "react-scripts": "0.9.5"
    },
    "scripts": {
        "start": "REACT_APP_URL=http://localhost:3001 react-scripts start",
        "build": "REACT_APP_URL=<REDACTED> react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject",
        "flow": "flow",
        "storybook": "start-storybook -p 9009 -s public",
        "build-storybook": "build-storybook -s public"
    }
}

circle:

machine:
    node:
        version: 6.10.3

test:
    override:
        - CI=true npm test

dependencies:
    override:
        - yarn --ignore-engines

deployment:
    master:
        branch: master
        commands:
            - firebase deploy --token "$FIREBASE_DEPLOY_TOKEN" --non-interactive

CircleCI output:

$ CI=true npm test

> frontend@0.1.0 test /home/ubuntu/<REDACTED>
> react-scripts test --env=jsdom

 FAIL  src/reducers/transactions/reducer.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'bind' of undefined
      
      at Runtime._createRuntimeFor (node_modules/jest-runtime/build/index.js:640:37)
      at handle (node_modules/worker-farm/lib/child/index.js:41:8)
      at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
      at emitTwo (events.js:106:13)
      at process.emit (events.js:191:7)

 FAIL  src/reducers/contacts/reducer.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'bind' of undefined
      
      at Runtime._createRuntimeFor (node_modules/jest-runtime/build/index.js:640:37)
      at handle (node_modules/worker-farm/lib/child/index.js:41:8)
      at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
      at emitTwo (events.js:106:13)
      at process.emit (events.js:191:7)

....

Test Suites: 9 failed, 9 total
Tests:       0 total
Snapshots:   0 total
Time:        11.745s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

CI=true npm test returned exit code 1
@VisorsJimmyTruong

This comment has been minimized.

Show comment
Hide comment
@VisorsJimmyTruong

VisorsJimmyTruong Nov 9, 2017

@natdm not sure if this will help or why it worked for me, but I blew away node modules and re-installed and the error went away.

VisorsJimmyTruong commented Nov 9, 2017

@natdm not sure if this will help or why it worked for me, but I blew away node modules and re-installed and the error went away.

@szimek

This comment has been minimized.

Show comment
Hide comment
@szimek

szimek Nov 10, 2017

I had the same error with a repo where I'm using Lerna and found this thread, while looking for a solution. It turned out that one old app was still using Jest v18, the other v21 and tests were failing with this bind error in the app with Jest v21.

I think that Lerna is supposed to somehow magically solve such problems, but I managed to fix it only when I updated Jest in both apps to v21.

szimek commented Nov 10, 2017

I had the same error with a repo where I'm using Lerna and found this thread, while looking for a solution. It turned out that one old app was still using Jest v18, the other v21 and tests were failing with this bind error in the app with Jest v21.

I think that Lerna is supposed to somehow magically solve such problems, but I managed to fix it only when I updated Jest in both apps to v21.

@yavoo

This comment has been minimized.

Show comment
Hide comment
@yavoo

yavoo Mar 27, 2018

I just solved the same issue with downgrading Node version to 8.9.4

yavoo commented Mar 27, 2018

I just solved the same issue with downgrading Node version to 8.9.4

@german1311

This comment has been minimized.

Show comment
Hide comment
@german1311

german1311 Apr 20, 2018

I've had this error even having default env(jdom), solved installing
npm install --save-dev babel-jest regenerator-runtime

german1311 commented Apr 20, 2018

I've had this error even having default env(jdom), solved installing
npm install --save-dev babel-jest regenerator-runtime

@jeff1evesque

This comment has been minimized.

Show comment
Hide comment
@jeff1evesque

jeff1evesque May 16, 2018

My package.json has the same version of jest-cli as babel-jest at 22.4.3. When I run my page.test.jsx, I get a really long output:

 FAIL  __tests__/layout/page.test.jsx (23.231s)
  PageLayout Component
    ✕ should render home route (135ms)
    ✕ should render login route (20ms)
    ✕ should render logout route (7ms)
    ✕ should render register route (26ms)
    ✕ should render analysis route (13ms)

  ● PageLayout Component › should render home route

    TypeError: Cannot read property 'bind' of undefined

      17 | const mapDispatchToProps = (dispatch) => {
      18 |     return {
    > 19 |         dispatchLayout: dispatch.bind(setLayout)
      20 |     }
      21 | }
      22 |

      at Function.mapDispatchToProps [as mapToProps] (import/redux/container/home-page.jsx:19:34)
      at mapToPropsProxy (node_modules/react-redux/lib/connect/wrapMapToProps.js:54:92)
      at Function.detectFactoryAndVerify (node_modules/react-redux/lib/connect/wrapMapToProps.js:63:19)
      at mapToPropsProxy (node_modules/react-redux/lib/connect/wrapMapToProps.js:54:46)
      at handleFirstCall (node_modules/react-redux/lib/connect/selectorFactory.js:38:21)
      at pureFinalPropsSelector (node_modules/react-redux/lib/connect/selectorFactory.js:85:81)
      at Object.runComponentSelector [as run] (node_modules/react-redux/lib/components/connectAdvanced.js:43:25)
      at Connect.initSelector (node_modules/react-redux/lib/components/connectAdvanced.js:195:23)
      at new Connect (node_modules/react-redux/lib/components/connectAdvanced.js:136:15)
      at constructClassInstance (node_modules/react-dom/cjs/react-dom.development.js:6801:20)
      at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:8336:9)
      at beginWork (node_modules/react-dom/cjs/react-dom.development.js:8982:16)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:11814:16)
      at workLoop (node_modules/react-dom/cjs/react-dom.development.js:11843:26)
      at renderRoot (node_modules/react-dom/cjs/react-dom.development.js:11874:9)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:12449:24)
      at performWork (node_modules/react-dom/cjs/react-dom.development.js:12370:9)
      at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:12347:5)
      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:12247:7)
      at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:12122:13)
      at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:12082:12)
      at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:12710:5)
      at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:12738:12)
      at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:12765:14)
      at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:16069:15)
      at node_modules/react-dom/cjs/react-dom.development.js:16488:14
      at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:12557:12)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:16484:17)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:16543:12)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)
      at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
      at mount (node_modules/enzyme/build/mount.js:19:10)
      at Object.<anonymous> (__tests__/layout/page.test.jsx:24:25)

The results repeat the above, for each it() test. Am I supposed to pass in my redux properties in the store for the <Provider>? The HomePageState is a connected redux container to the HomePage component. So, I'm curious if I have to pass the properties associated with the dispatchLayout from the <Provider>, or the <MainRoute> of the page.test.jsx?

Note: if anyone is interested, the full issue for my above problem can be further reviewed.

jeff1evesque commented May 16, 2018

My package.json has the same version of jest-cli as babel-jest at 22.4.3. When I run my page.test.jsx, I get a really long output:

 FAIL  __tests__/layout/page.test.jsx (23.231s)
  PageLayout Component
    ✕ should render home route (135ms)
    ✕ should render login route (20ms)
    ✕ should render logout route (7ms)
    ✕ should render register route (26ms)
    ✕ should render analysis route (13ms)

  ● PageLayout Component › should render home route

    TypeError: Cannot read property 'bind' of undefined

      17 | const mapDispatchToProps = (dispatch) => {
      18 |     return {
    > 19 |         dispatchLayout: dispatch.bind(setLayout)
      20 |     }
      21 | }
      22 |

      at Function.mapDispatchToProps [as mapToProps] (import/redux/container/home-page.jsx:19:34)
      at mapToPropsProxy (node_modules/react-redux/lib/connect/wrapMapToProps.js:54:92)
      at Function.detectFactoryAndVerify (node_modules/react-redux/lib/connect/wrapMapToProps.js:63:19)
      at mapToPropsProxy (node_modules/react-redux/lib/connect/wrapMapToProps.js:54:46)
      at handleFirstCall (node_modules/react-redux/lib/connect/selectorFactory.js:38:21)
      at pureFinalPropsSelector (node_modules/react-redux/lib/connect/selectorFactory.js:85:81)
      at Object.runComponentSelector [as run] (node_modules/react-redux/lib/components/connectAdvanced.js:43:25)
      at Connect.initSelector (node_modules/react-redux/lib/components/connectAdvanced.js:195:23)
      at new Connect (node_modules/react-redux/lib/components/connectAdvanced.js:136:15)
      at constructClassInstance (node_modules/react-dom/cjs/react-dom.development.js:6801:20)
      at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:8336:9)
      at beginWork (node_modules/react-dom/cjs/react-dom.development.js:8982:16)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:11814:16)
      at workLoop (node_modules/react-dom/cjs/react-dom.development.js:11843:26)
      at renderRoot (node_modules/react-dom/cjs/react-dom.development.js:11874:9)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:12449:24)
      at performWork (node_modules/react-dom/cjs/react-dom.development.js:12370:9)
      at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:12347:5)
      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:12247:7)
      at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:12122:13)
      at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:12082:12)
      at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:12710:5)
      at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:12738:12)
      at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:12765:14)
      at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:16069:15)
      at node_modules/react-dom/cjs/react-dom.development.js:16488:14
      at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:12557:12)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:16484:17)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:16543:12)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)
      at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
      at mount (node_modules/enzyme/build/mount.js:19:10)
      at Object.<anonymous> (__tests__/layout/page.test.jsx:24:25)

The results repeat the above, for each it() test. Am I supposed to pass in my redux properties in the store for the <Provider>? The HomePageState is a connected redux container to the HomePage component. So, I'm curious if I have to pass the properties associated with the dispatchLayout from the <Provider>, or the <MainRoute> of the page.test.jsx?

Note: if anyone is interested, the full issue for my above problem can be further reviewed.

@rickhanlonii

This comment has been minimized.

Show comment
Hide comment
@rickhanlonii

rickhanlonii May 17, 2018

Collaborator

Hey @jeff1evesque, in your case I think that dispatch is really undefined

Collaborator

rickhanlonii commented May 17, 2018

Hey @jeff1evesque, in your case I think that dispatch is really undefined

@normdoow

This comment has been minimized.

Show comment
Hide comment
@normdoow

normdoow May 26, 2018

when running my tests I get an error Test suite failed to run, TypeError: cannot read property myProperty of undefined I have followed this to install jest https://medium.com/react-native-training/learning-to-test-react-native-with-jest-part-1-f782c4e30101 and I am on react-native. What is wrong with how my package.json is that it isn't working?

{
  "name": "CoffeeApp",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-jest": "^23.0.0",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "jest": "^23.0.0",
    "react-test-renderer": "^16.4.0"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "prop-types": "^15.6.1",
    "query-string": "^6.0.0",
    "react": "16.2.0",
    "react-native": "0.52.0",
    "react-native-elements": "^1.0.0-beta4",
    "react-native-gesture-handler": "^1.0.0",
    "react-native-mixpanel": "0.0.16",
    "react-native-star-rating": "^1.0.9",
    "react-native-tab-view": "^0.0.78",
    "react-native-vector-icons": "^4.6.0",
    "react-navigation": "^1.5.11",
    "react-redux": "^5.0.7",
    "redux": "^3.7.2",
    "redux-persist": "^5.9.1",
    "tipsi-stripe": "^5.2.0"
  }
}

Thanks!

normdoow commented May 26, 2018

when running my tests I get an error Test suite failed to run, TypeError: cannot read property myProperty of undefined I have followed this to install jest https://medium.com/react-native-training/learning-to-test-react-native-with-jest-part-1-f782c4e30101 and I am on react-native. What is wrong with how my package.json is that it isn't working?

{
  "name": "CoffeeApp",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-jest": "^23.0.0",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "jest": "^23.0.0",
    "react-test-renderer": "^16.4.0"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "prop-types": "^15.6.1",
    "query-string": "^6.0.0",
    "react": "16.2.0",
    "react-native": "0.52.0",
    "react-native-elements": "^1.0.0-beta4",
    "react-native-gesture-handler": "^1.0.0",
    "react-native-mixpanel": "0.0.16",
    "react-native-star-rating": "^1.0.9",
    "react-native-tab-view": "^0.0.78",
    "react-native-vector-icons": "^4.6.0",
    "react-navigation": "^1.5.11",
    "react-redux": "^5.0.7",
    "redux": "^3.7.2",
    "redux-persist": "^5.9.1",
    "tipsi-stripe": "^5.2.0"
  }
}

Thanks!

@SimenB

This comment has been minimized.

Show comment
Hide comment
@SimenB

SimenB May 26, 2018

Collaborator

Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Collaborator

SimenB commented May 26, 2018

Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@hedgepigdaniel

This comment has been minimized.

Show comment
Hide comment
@hedgepigdaniel

hedgepigdaniel Jul 18, 2018

I had this issue because my project did no explicitly depend on jest-cli, but because it was a dependency of jest, it was installed. When I installed another package (react-codemod) with a dependency on an older version of jest-cli, yarn chose the older one. I solved the problem by adding an explicity dependency in my project on the version of jest-cli matching the version of jest in my project.

hedgepigdaniel commented Jul 18, 2018

I had this issue because my project did no explicitly depend on jest-cli, but because it was a dependency of jest, it was installed. When I installed another package (react-codemod) with a dependency on an older version of jest-cli, yarn chose the older one. I solved the problem by adding an explicity dependency in my project on the version of jest-cli matching the version of jest in my project.

@SimenB

This comment has been minimized.

Show comment
Hide comment
@SimenB

SimenB Jul 18, 2018

Collaborator

wat, react-codemod depends on Jest? That has to be a bug

Collaborator

SimenB commented Jul 18, 2018

wat, react-codemod depends on Jest? That has to be a bug

@hedgepigdaniel

This comment has been minimized.

Show comment
Hide comment
@hedgepigdaniel

hedgepigdaniel Jul 18, 2018

It's a bit strange, but it shouldn't matter. Maybe jest should not depend on jest-cli, so that users are forced to add an explicit dependency to their project (at the correct version) if they want to use it?

Including the appropriate peerDependencies should at least provide a warning of this kind of problem. (E.g. jest-cli should have a peer dependency on a version of jest that works correctly with it)

hedgepigdaniel commented Jul 18, 2018

It's a bit strange, but it shouldn't matter. Maybe jest should not depend on jest-cli, so that users are forced to add an explicit dependency to their project (at the correct version) if they want to use it?

Including the appropriate peerDependencies should at least provide a warning of this kind of problem. (E.g. jest-cli should have a peer dependency on a version of jest that works correctly with it)

@SimenB

This comment has been minimized.

Show comment
Hide comment
@SimenB

SimenB Jul 18, 2018

Collaborator

jest had a bug previously, fixed in newer versions. react-codemod` depends on a version of jest almost 2 years old. It shouldn't (it's a dev dependency though, so the version is really orthogonal)

Collaborator

SimenB commented Jul 18, 2018

jest had a bug previously, fixed in newer versions. react-codemod` depends on a version of jest almost 2 years old. It shouldn't (it's a dev dependency though, so the version is really orthogonal)

@hedgepigdaniel

This comment has been minimized.

Show comment
Hide comment
@hedgepigdaniel

hedgepigdaniel Jul 19, 2018

I think this is a more specific case of #5913. In my case, after installing react-codemod I had to add explicit dependencies to my project for jest-cli and jest-environment-jsdom for my jest setup to continue to work.

hedgepigdaniel commented Jul 19, 2018

I think this is a more specific case of #5913. In my case, after installing react-codemod I had to add explicit dependencies to my project for jest-cli and jest-environment-jsdom for my jest setup to continue to work.

@vaibhav-systango

This comment has been minimized.

Show comment
Hide comment
@vaibhav-systango

vaibhav-systango Aug 30, 2018

@Harishn28 @cpenarrieta @szimek @natdm @kentcdodds @cpojer I'm still getting this bind issue with jest version 22

vaibhav-systango commented Aug 30, 2018

@Harishn28 @cpenarrieta @szimek @natdm @kentcdodds @cpojer I'm still getting this bind issue with jest version 22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment