Я застрял на нем с 5 дней. Я получаю сообщение об ошибке «Jest обнаружил неожиданный токен». Я пробовал все предоставленные решения, соответствующие этому. Никто из них не работал для меня. Ошибка
import MyNavbar from '../../components/MyNavbar'
5 | test("Should return MyNavbar component", () => {
> 6 | const wrapper = shallow(<MyNavbar />)
| ^
7 | expect(wrapper.find('.navbar-brand').find('kbd').text()).toBe("Expensify")
Мой .babelr c файл
{
"env": {
"development": {
"presets": ["env", "react"],
"plugins": ["transform-object-rest-spread", "transform-class-properties"]
},
"test": {
"presets": [
["env", {
"targets": {
"node": "current"
}
}, "react"]
],
"plugins": ["@babel/plugin-proposal-object-rest-spread", "transform-class-properties"]
}
}
}
и мой пакет. json is
"dependencies": {
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
"babel-cli": "^6.26.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^25.3.0",
"babel-loader": "7",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"bootstrap": "^4.4.1",
"css-loader": "^3.4.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"jest": "^25.3.0",
"live-server": "^1.2.1",
"moment": "^2.24.0",
"node-sass": "^4.13.1",
"raf": "^3.4.1",
"react": "^16.13.1",
"react-addons-shallow-compare": "^15.6.2",
"react-bootstrap": "^1.0.0",
"react-dates": "^21.8.0",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-test-renderer": "^16.13.1",
"redux": "^4.0.5",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.3",
"uuid": "^7.0.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
}