Jest Обнаружен неожиданный токен после исправления неправильных зависимостей от babel - PullRequest
0 голосов
/ 24 августа 2018

Это мой package.json У меня есть "babel-core": "7.0.0-bridge.0", но я все еще получаю эту ошибку. После новой установки npm я получаю новую ошибку о Jest, обнаружил неожиданный токен.

  "dependencies": {
    "axios": "^0.18.0",
    "babel-eslint": "^8.2.2",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "classnames": "2.2.5",
    "core-js": "2.5.5",
    "enzyme-to-json": "^3.3.0",
    "form-data": "^2.3.2",
    "jest": "^23.4.1",
    "json-parse-better-errors": "^1.0.2",
    "yarn": "^1.7.0"
  },
  "devDependencies": {
    "@babel/core": "7.0.0-beta.46",
    "@babel/plugin-proposal-class-properties": "^7.0.0-beta.42",
    "@babel/preset-env": "7.0.0-beta.46",
    "@babel/preset-react": "7.0.0-beta.46",
    "@babel/register": "7.0.0-beta.46",
    "@babel/runtime": "7.0.0-beta.42",
    "babel-core": "7.0.0-bridge.0",
    "babel-loader": "^7.0.0"
  }

У меня новая ошибка сейчас

Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.

     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" con
fig option.

{"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Enzyme from 'enzyme';

Это мой файл:

import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });

Это мой файл babelrc:

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "modules": false
      }
    ],
    "@babel/react"
  ],
  "plugins": [
    "react-hot-loader/babel",
    "@babel/plugin-proposal-class-properties",
    "transform-class-properties"
  ]
}
...