Я не могу обойти эту проблему.Я перепробовал все (так много!) Я мог найти эту проблему в Интернете, но, похоже, это не помогло.Вот конфигурации
package.json
{
"scripts": {
"test": "jest --no-cache",
"test:watch": "npm run test -- --watch"
},
"devDependencies": {
"@babel/core": "^7.5.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.5.4",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-module-resolver": "^3.2.0",
"babel-plugin-recharts": "^1.2.0",
"babel-plugin-transform-imports": "^2.0.0",
"flow-bin": "^0.106.1",
"flow-typed": "^2.6.1",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.9.0",
"lodash-webpack-plugin": "^0.11.5",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
"webpack": "^4.35.3",
"webpack-async-chunk-names-plugin": "^0.1.1",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.5",
"webpack-dashboard": "^3.0.7",
"webpack-dev-server": "^3.7.2",
"webpack-merge": "^4.2.1"
},
"dependencies": {
"@material-ui/core": "^4.2.0",
"@material-ui/icons": "^4.2.1",
"clsx": "1.0.2",
"fg-loadcss": "^2.1.0",
"lodash": "^4.17.15",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-gradient": "^1.0.1",
"react-redux": "^7.1.0",
"react-router-dom": "^5.0.1",
"recharts": "^1.6.2",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0"
}
}
jest.config.js
module.exports = {
"testRegex": "((\\.|/*.)(test))\\.js?$",
"transform": {
"^.+\\.(js|ts)x?$": "<rootDir>/node_modules/babel-jest"
}
}
babel.config.js
module.exports = function (api) {
api.cache(true)
const presets = [
["@babel/preset-env", {"modules": false}],
["@babel/preset-flow", {"all": true}],
"@babel/preset-react",
]
const plugins = [
"lodash",
"recharts",
//"@babel/plugin-proposal-class-properties",
["module-resolver", {
"root": ["./"],
"alias": {
"projectRoot": "./",
"src": "./src/",
},
}],
["transform-imports", {
"@material-ui/core": {
//supports only upto level 2 (@material-ui/core/Tabs/TabIndicator <- level 3 not supported)
"transform": "@material-ui/core/${member}",
},
}],
]
return {
presets,
plugins
}
}
ошибка, которую я получаю
Details:
src/helpers/__tests__/utils.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { getDateString, getTimeString } from "../utils";
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
Это очень расстраивает, потому что ничего не работает.До сих пор я пробовал неисчислимые вещи, но это, похоже, не работает.Любая помощь могла бы быть полезна!