vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.82k stars 26.85k forks source link

Jest test error #5462

Closed Tevinthuku closed 6 years ago

Tevinthuku commented 6 years ago

Bug report

Whenever I try to run a yarn test I get

image

Describe the bug

I installed jest and the other necessary dependencies for testing in an existing project, here's my package.json

{
  "name": "artispace",
  "version": "1.0.0",
  "author": "Tevin Thuku",
  "license": "MIT",
  "scripts": {
    "dev": "cross-env NODE_ENV=development node server.js",
    "flow": "flow",
    "build": "next build",
    "start": "cross-env NODE_ENV=production node server.js",
    "react-devtools": "react-devtools",
    "test": "jest"
  },
  "dependencies": {
    "@dr-kobros/react-webfont-loader": "^8.0.0",
    "@material-ui/core": "^3.1.0",
    "@material-ui/docs": "^1.0.0-alpha.3",
    "@material-ui/icons": "^3.0.1",
    "@material-ui/lab": "^3.0.0-alpha.15",
    "@zeit/next-css": "^0.2.0",
    "add": "^2.0.6",
    "africastalking": "^0.3.2",
    "animated": "^0.2.2",
    "apollo-boost": "^0.1.6",
    "babel-plugin-bucklescript": "^0.4.0",
    "babel-plugin-inline-dotenv": "^1.1.2",
    "babel-plugin-transform-inline-environment-variables": "^0.4.3",
    "body-parser": "^1.18.3",
    "copy-to-clipboard": "^3.0.8",
    "cors": "^2.8.4",
    "crocks": "^0.10.1",
    "crypto-js": "^3.1.9-1",
    "draft-js": "^0.10.5",
    "draft-js-hashtag-plugin": "^2.0.3",
    "draft-js-linkify-plugin": "^2.0.1",
    "draft-js-mention-plugin": "^3.0.4",
    "draft-js-plugins-editor": "^2.1.1",
    "draft-js-prism-plugin": "^0.1.3",
    "draftjs-to-markdown": "^0.5.1",
    "eslint": "^4.19.1",
    "express": "^4.16.3",
    "express-graphql": "^0.6.12",
    "express-session": "^1.15.6",
    "firebase": "^5.0.4",
    "firebase-admin": "^5.12.1",
    "get-random-values": "^1.2.0",
    "graphql": "^0.13.2",
    "greenlet": "^1.0.1",
    "isomorphic-unfetch": "^2.0.0",
    "jss": "^9.8.1",
    "jssha": "^2.3.1",
    "marked": "^0.4.0",
    "memoizee": "^0.4.13",
    "moment": "^2.22.2",
    "moment-timezone": "^0.5.21",
    "natural": "^0.6.1",
    "next": "^7.0.2",
    "next-offline": "^2.7.3",
    "next-routes": "^1.4.2",
    "node-schedule": "^1.3.0",
    "nprogress": "^0.2.0",
    "prismjs": "^1.15.0",
    "prop-types": "^15.6.1",
    "react": "^16.5.2",
    "react-apollo": "^2.1.4",
    "react-beautiful-dnd": "^7.1.3",
    "react-dom": "^16.5.2",
    "react-dropzone": "^4.2.13",
    "react-jss": "^8.4.0",
    "react-redux": "^5.0.7",
    "react-spring": "^5.3.20",
    "react-swipeable-views": "^0.12.13",
    "react-text-mask": "^5.4.2",
    "reduce-reducers": "^0.4.3",
    "redux": "^4.0.0",
    "redux-actions": "^2.4.0",
    "redux-devtools-extension": "^2.13.5",
    "redux-thunk": "^2.3.0",
    "session-file-store": "^1.2.0",
    "sitemap": "^2.0.1",
    "socket.io": "^2.1.1",
    "socket.io-client": "^2.1.1",
    "stockroom": "^1.0.1",
    "throttle-debounce": "^1.0.1",
    "twit": "^2.2.11",
    "unistore": "^3.0.6",
    "uuid": "^3.2.1",
    "worker-loader": "^2.0.0",
    "workerize-loader": "^1.0.2",
    "yarn": "^1.7.0"
  },
  "devDependencies": {
    "@babel/core": "^7.1.2",
    "babel-core": "^6.26.3",
    "babel-eslint": "^8.2.3",
    "babel-jest": "^23.6.0",
    "babel-plugin-transform-flow-strip-types": "^6.22.0",
    "cross-env": "^5.2.0",
    "enzyme": "^3.7.0",
    "enzyme-adapter-react-16": "^1.6.0",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-prettier": "^2.6.2",
    "eslint-plugin-react": "^7.8.2",
    "flow-bin": "^0.81.0",
    "jest": "^23.6.0",
    "prettier": "^1.14.3",
    "prettier-eslint": "^8.8.2",
    "react-addons-test-utils": "^15.6.2",
    "react-test-renderer": "^16.5.2",
    "svg-inline-loader": "^0.8.0"
  }
}

my .babelrc


{
  "presets": ["next/babel"],
  "plugins": ["transform-flow-strip-types"]
}

To Reproduce

  1. yarn (to install all deps)
  2. yarn test (to run the tests)

Expected behavior

The tests should run as expected

Screenshots

image

System information - OS: [Windows]

timneutkens commented 6 years ago

"babel-core": "^6.26.3",

Please follow the with-jest example:

https://github.com/zeit/next.js/blob/canary/examples/with-jest/package.json#L11