Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

enter image description here

What might have went wrong.

like image 726
Harish_N Avatar asked Mar 09 '17 10:03

Harish_N


2 Answers

React 17+

  "devDependencies": {
    "@testing-library/dom": "^8.11.1",
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "@types/jest": "^26.0.24",
    "@types/react": "^17.0.27",
    "@types/react-table": "^7.7.7",
    "jest": "26.0.1",
    "ts-jest": "26.0.0",
    "typescript": "^4.5.4"
  }

Error was on jest 27+ version but after setting to 26 it works well.

like image 129
Romantik Zhurb Avatar answered Oct 08 '22 06:10

Romantik Zhurb


Try to re-install both jest and jest babel last versions

npm install --save-dev jest

npm install --save-dev babel-jest regenerator-runtime

And re-run the test, it works for me

like image 29
Hussam Kurd Avatar answered Oct 08 '22 06:10

Hussam Kurd