【发布时间】:2020-07-20 19:24:10
【问题描述】:
我正在使用 create-react-app。当我输入“npm test”时,出现“找不到模块”错误。我虽然 jest 已经安装在 create-react-app 中。以下是我的 package.json。有什么想法吗?
{
"proxy": "http://localhost:5000",
"name": "276_project",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bulma": "^0.9.0",
"jwt-decode": "^2.2.0",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-bootstrap": "^1.2.2",
"react-cart-components": "^2.1.0",
"react-dom": "^16.13.1",
"react-hook-form": "^5.7.2",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"react-stripe-checkout": "^2.6.3",
"react-toastify": "^6.0.6",
"serve": "^11.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
【问题讨论】:
-
你还有
create-react-app设置的测试文件吗?也许给我们您的文件目录结构、完整错误消息以及生成该错误消息的文件的快照,可能会有所帮助。 Jest 很可能正在运行,但随后在您的一个测试文件中遇到了障碍。
标签: javascript reactjs testing create-react-app