adriantoine / enzyme-to-json

Snapshot test your Enzyme wrappers
MIT License
947 stars 64 forks source link

Cannot read property '$$typeof' of undefined #125

Closed alanyinjs closed 5 years ago

alanyinjs commented 5 years ago

I am trying to implement enzyme-to-json in my project with enzyme and jest and when I ran test for one of my components, I have come across the following issue: capture

I have set up my jest like this:

  "jest": {
    "collectCoverageFrom": [
      "static/js/react-src/**/*.{js,jsx}"
    ],
    "setupFiles": [
      "<rootDir>/static/jest/scripts/polyfills.js",
      "<rootDir>/static/jest/setup-jest.js",
      "<rootDir>/static/jest/setupTests.js"
    ],
    "testMatch": [
      "<rootDir>/static/js/react-src/**/__tests__/**/*.{js,jsx}",
      "<rootDir>/static/js/react-src/**/?(*.)(spec|test).{js,jsx,mjs}"
    ],
    "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
      "\\.(css|scss)$": "identity-obj-proxy"
    },
    "testEnvironment": "node",
    "transform": {
      "^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/static/jest/scripts/cssTransform.js",
      "^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/static/jest/scripts/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
    ],
    "moduleFileExtensions": [
      "web.js",
      "mjs",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  }

And I have run npm test HelpTooltip from the terminal:

  "scripts": {
    "test": "..\\..\\.tools\\nodejs\\node.exe static\\jest\\test.js --env=jsdom"
  },

I am using the following versions of packages:

"react": "16.2.0",
"babel-jest": "23.6.0",
"enzyme":"3.3.0",
"enzyme-adapter-react-16":"1.1.1",
"enzyme-to-json": "3.3.5",
"jest":"23.6.0"

I am suspecting this has to do with version compatibility of those packages. But I can't figure out what version I should choose. It could be some other problems that I am not aware of...

Btw, the test case ran without problem without enzyme-to-json being installed and configured. I would just like to implement it so that the snapshot can be formatted properly.

alanyinjs commented 5 years ago

This seems to be caused by what's mentioned in #122

VincentLanglet commented 5 years ago

Indeed, duplicate