我正在用ReactJs & Node为一个类编写一个测试网站,运行测试时遇到了困难。我试过通过npm install重新安装软件包。升级和降级到“testing-library”的某些版本,但这会导致更多失败的测试。我试过安装npm i helpers/helper
这是我的package.json
{
"name": "landingpage-react-template",
"private": true,
"dependencies": {
"@testing-library/react": "^9.3.2",
"axios": "^0.27.2",
"bcrypt": "^5.0.1",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"database.js": "^0.0.1",
"detect-file": "^1.0.0",
"detect-libc": "^2.0.1",
"emailjs-com": "^2.6.4",
"express": "^4.18.1",
"express-fileupload": "^1.4.0",
"express-handlebars": "^6.0.6",
"multer": "^1.4.5-lts.1",
"mv": "^2.1.1",
"mysql": "^2.18.1",
"mysql2": "^2.3.3",
"nodemailer": "^6.8.0",
"react": "^17.0.1",
"react-cookie": "^4.1.1",
"react-dom": "^17.0.1",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"react-youtube": "^9.0.1",
"sequelize": "^6.23.2",
"sequelize-cli": "^6.5.1",
"smooth-scroll": "^16.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/user-event": "^14.4.3",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"enzyme": "^3.11.0"
}
}
这是运行npm测试后的错误
FAIL src/pages/components/resetPasswordPage/resetPasswordComponent.test.jsx
● Test suite failed to run
Cannot find module '@testing-library/dom/dist/helpers.js' from 'node_modules/@testing-library/user-event/dist/cjs/utils/misc/getWindow.js'
Require stack:
node_modules/@testing-library/user-event/dist/cjs/utils/misc/getWindow.js
node_modules/@testing-library/user-event/dist/cjs/utils/dataTransfer/Clipboard.js
node_modules/@testing-library/user-event/dist/cjs/event/behavior/click.js
node_modules/@testing-library/user-event/dist/cjs/event/dispatchEvent.js
node_modules/@testing-library/user-event/dist/cjs/document/prepareDocument.js
node_modules/@testing-library/user-event/dist/cjs/setup/setup.js
node_modules/@testing-library/user-event/dist/cjs/setup/index.js
node_modules/@testing-library/user-event/dist/cjs/index.js
src/pages/components/resetPasswordPage/resetPasswordComponent.test.jsx
at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
at Object.<anonymous> (node_modules/@testing-library/user-event/dist/cjs/utils/misc/getWindow.js:5:18)
1条答案
按热度按时间xzlaal3s1#
@testing-library/dom
是user-event
的对等依赖项,需要在项目中单独安装。