enzymejs / enzyme

JavaScript Testing utilities for React
https://enzymejs.github.io/enzyme/
MIT License
19.95k stars 2.01k forks source link

TypeError: Super expression must either be null or a function, not undefined #1443

Closed dschinkel closed 6 years ago

dschinkel commented 6 years ago

Can't figure this out. I've done this many times, updated react projects from 15 to 16 including enzyme to the 16 adaptor and it's been fine. But for this project it's complaining. I updated react from 15 to 16. When I try running my mocha test for the first time I get:

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint no-use-before-define: 0 */
   at _inherits (/Users/daveschinkel/code/projects/consulting/diamond/fox/dcg-web-app/dcg-shared-react/node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:45:113)
    at /Users/daveschinkel/code/projects/consulting/diamond/fox/dcg-web-app/dcg-shared-react/node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:190:3
    at Object.<anonymous> (/Users/daveschinkel/code/projects/consulting/diamond/fox/dcg-web-app/dcg-shared-react/node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:455:2)
    at Module._compile (module.js:569:30)
                                                                                                      ^

TypeError: Super expression must either be null or a function, not undefined

I've setup enzyme like I always do which has worked fine in other react projects:

import React from 'react'
import Enzyme from 'enzyme';
import chai, { expect } from 'chai';
import { shallow, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new Adapter() });

package.json

{
  "name": "",
  "author": "",
  "version": "1.7.18",
  "description": "",
  "main": "lib/index.js",
  "files": [
    "lib/",
    "README.md"
  ],
  "engines": {
    "node": "6.x"
  },
  "directories": {},
  "repository": {
    "type": "git",
    "url": "xxxxxxxxxx"
  },
  "dependencies": {
    "axios": "^0.15",
    "babel-core": "^6.7.7",
    "babel-eslint": "^6.0.4",
    "babel-loader": "^6.2.4",
    "babel-plugin-webpack-loaders": "^0.7.1",
    "classnames": "^2.2.5",
    "cleave.js": "1.0.2",
    "hls.js": "^0.6.18",
    "lodash": "^4.16.1",
    "moment": "2.15.2",
    "postcss-import": "^9.1.0",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-cookie": "^1.0.4",
    "react-css-themr": "^1.3.0",
    "react-dotdotdot": "^1.0.17",
    "react-lazy-load": "^3.0.11",
    "react-markdown": "^2.4.4",
    "react-redux": "^4.4.5",
    "react-router": "^2.4.0",
    "react-router-redux": "^4.0.4",
    "react-slider": "^0.9.0",
    "react-timeout": "^1.0.1",
    "react-truncate": "^2.1.1",
    "redux": "^3.5.2",
    "scriptjs": "^2.5.8",
    "sinon": "^1.17.6",
    "validator": "^6.2.1",
    "webpack": "^2.3.2",
    "xml2js": "^0.4.17"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.14.0",
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-assets": "^0.2.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "1.5.1",
    "chai": "^4.1.2",
    "chai-enzyme": "^0.8.0",
    "css-modules-require-hook": "^4.0.6",
    "documentation": "^4.0.0-beta5",
    "enzyme": "^2.4.1",
    "enzyme-adapter-react-16": "^1.1.0",
    "eslint": "^3.18.0",
    "eslint-config-airbnb": "^14.1.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^4.0.0",
    "eslint-plugin-promise": "^3.5.0",
    "eslint-plugin-react": "^6.10.3",
    "expect": "^1.20.2",
    "expect-jsx": "^2.6.0",
    "jsdom": "^11.5.1",
    "mocha": "^4.0.1",
    "postcss": "^5.0.21",
    "postcss-modules-resolve-path": "^1.0.0",
    "postcss-use": "^2.2.0",
    "react-addons-test-utils": "^15.0.1",
    "react-styleguidist": "^2.3.1",
    "stylelint": "^6.7.0"
  }
}
ljharb commented 6 years ago

This title is a duplicate of #1172. Is it perhaps the same issue?

Generally, this often occurs when there's a circular dependency somewhere; I'm not sure where there would be one here.

dschinkel commented 6 years ago

yea I took a look at that issue as well. Let me investigate more. thx

dschinkel commented 6 years ago

eh just needed to install "babel-core". thought I did already but didn't.