btholt / complete-intro-to-react-v4

The Complete Intro to React, as given for Frontend Masters
https://frontendmasters.com/learn/react/
1.14k stars 248 forks source link

Test suite failed to run #28

Closed nakita-strangeways closed 5 years ago

nakita-strangeways commented 5 years ago

When starting the Jest Snapshot Tests, the debug says "snapshot missing" in the Details.test.js, and when I run npx jest in my terminal, it fails and gives me:

Test suite failed to run, Plugin/Preset files are not allowed to export objects, only functions. In /Users/user/Documents/complete-intro-to-react-v4/node_modules/babel-preset-react/lib/index.js

.

Ive cloned the repo and gone on straight from there, any ideas?

the-nick-wilson commented 5 years ago

I ran into the same thing. Seems like there's an incompatibility between the most recent version of Jest and babel-core 6.26.3 (since in the video, he has you install the most recent version of Jest with npm install -D jest react-test-renderer).

You'll want to go to the package.json for the "testing" branch and see if the versions match what you have. Once I changed "jest" back to "^23.5.0", it worked (yours is probably "^24.1.0":

  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-eslint": "^10.0.1",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "eslint": "^5.12.1",
    "eslint-config-prettier": "^4.0.0",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-jsx-a11y": "^6.2.0",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint-plugin-react": "^7.12.4",
    "jest": "^23.5.0",
    "parcel-bundler": "^1.11.0",
    "prettier": "^1.16.1",
    "react-test-renderer": "^16.8.3"
  },
gitbreaker222 commented 5 years ago

@btholt maybe it is possible to add this info to the video description here: https://frontendmasters.com/courses/intermediate-react/jest-snapshot-tests/

Example:

"Learn to run your first Jest [...] Note to install jest version ^23.5.0 to prevent issue 28

Thomaspantioras commented 5 years ago

I run npm install --save-dev jest and it worked with version ^23.6.0

1Marc commented 5 years ago

We just updated the annotation, code and website to point to ^23.5.0 https://btholt.github.io/complete-intro-to-react-v4/testing/

Thanks for your help all 🙌 @nakita-strangeways @the-nick-wilson @gitbreaker222 @Thomaspantioras !