Skip to content

Requires Babel "^7.0.0-0", but was loaded with "6.26.3". #6913

@dmurphy5

Description

@dmurphy5

🐛 Bug Report

I get the following message when trying to run tests. None of the solutions in the documentation or other issues work.

    Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.

      at throwVersionError (node_modules/@babel/plugin-proposal-class-properties/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
      at Object.assertVersion (node_modules/@babel/plugin-proposal-class-properties/node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
      at _default (node_modules/@babel/plugin-proposal-class-properties/lib/index.js:81:7)
      at node_modules/@babel/plugin-proposal-class-properties/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
          at Array.map (<anonymous>)

To Reproduce

Relevant package.json dependencies/config

{
   "devDependencies": {
        "@babel/core": "^7.0.0",
        "@babel/plugin-proposal-class-properties": "^7.0.0",
        "@babel/plugin-proposal-decorators": "^7.0.0",
        "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
        "@babel/plugin-syntax-dynamic-import": "^7.0.0",
        "@babel/preset-env": "^7.0.0",
        "@babel/preset-react": "^7.0.0",
        "@babel/register": "^7.0.0",
        "babel-core": "^7.0.0-bridge.0",
        "babel-jest": "^23.4.2",
        "babel-loader": "^8.0.0",
        "jest": "^23.5.0",
        "jest-environment-jsdom": "^23.4.0",
        "jest-junit": "^3.6.0",
        "jest-transform-graphql": "^2.1.0",
        "regenerator-runtime": "^0.12.1"
    },
   "jest": {
        "coveragePathIgnorePatterns": [
            "node_modules",
            "/*.graphql"
        ],
        "transform": {
            "\\.(gql|graphql)$": "jest-transform-graphql",
            "^.+\\.js$": "babel-jest"
        },
        "setupFiles": [
            "<rootDir>/src/jestSetup.js"
        ],
        "snapshotSerializers": [
            "enzyme-to-json/serializer"
        ],
        "testResultsProcessor": "jest-junit"
    }
}

.babelrc

{
    "presets": ["@babel/preset-react"],
    "plugins": [
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-object-rest-spread",
        "@babel/plugin-syntax-dynamic-import",
        ["@babel/plugin-proposal-decorators", { "legacy": true }]
    ],
    "env": {
        "test": {
            "presets": ["@babel/preset-env", "@babel/preset-react"]
        }
    }
}

jestSetup.js

import 'regenerator-runtime';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

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

Expected behavior

Jest runs correctly

Link to repl or repo (highly encouraged)

Please provide either a repl.it demo or a minimal repository on GitHub.

Issues without a reproduction link are likely to stall.

Run npx envinfo --preset jest

Throws the follwing error

(node:792) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions