Я работаю над модульным тестом и тестом моментальных снимков с использованием Jest в своем веб-приложении React. У меня есть два файла.
1.component.unit.test. js (путь: - APP / src /component.unit.test.js)
2.component.test. js (путь: - APP / tests / component.test. js)
, поэтому в основном в первом файле я делаю модульное тестирование, а в другом тесте снимка. Для запуска тестовых случаев я использую команду npm test . первый тестовый пример выполняется, но команда запуска npm не включает второй файл.
пакет. json
{
"name": "learn",
"version": "0.1.0",
"private": true,
"dependencies": {
"@date-io/date-fns": "^1.3.9",
"@material-ui/core": "^4.8.0",
"@material-ui/icons": "^4.2.1",
"@material-ui/pickers": "^3.2.4",
"axios": "^0.18.0",
"bootstrap-daterangepicker": "^3.0.5",
"bugsnag-js": "^4.7.3",
"bugsnag-react": "^1.1.1",
"chroma-js": "^2.0.2",
"clsx": "^1.0.4",
"date-fns": "^2.0.1",
"file-saver": "^2.0.2",
"history": "^4.7.2",
"jquery": "^3.4.1",
"material-ui": "^0.20.1",
"material-ui-icons": "^1.0.0-beta.36",
"material-ui-search-bar": "^1.0.0-beta.10",
"moment": "^2.22.1",
"particles.js": "^2.0.0",
"prop-types": "^15.7.2",
"react": "^16.4.2",
"react-bootstrap-daterangepicker": "^4.1.0",
"react-dom": "^16.4.2",
"react-dual-listbox": "^1.3.2",
"react-hot-loader": "^4.3.4",
"react-image-show": "^0.3.4",
"react-print": "^1.3.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.0.1",
"react-router-hash-link": "^1.2.2",
"react-scripts": "^1.1.5",
"react-select": "^2.1.2",
"react-select-material-ui": "^5.1.0",
"redux": "^4.0.0",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"styled-components": "^4.4.0",
"typeface-roboto": "0.0.54"
},
"scripts": {
"start": "cp ./src/env/config.dev.js ./src/config.js && react-app-rewired start",
"build:prod": "cp ./src/env/config.production.js ./src/config.js && react-app-rewired build",
"build:dev": "cp ./src/env/config.dev.js ./src/config.js && react-app-rewired build",
"build:staging": "cp ./src/env/config.staging.js ./src/config.js && react-app-rewired build",
"build:demo": "cp ./src/env/config.demo.js ./src/config.js && react-app-rewired build",
"build:staging:serve": "npm run build:staging && serve -s build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-app-rewired eject"
},
"devDependencies": {
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"eslint-config-google": "^0.9.1",
"husky": "^1.3.1",
"lint-staged": "^8.1.0",
"prettier": "1.14.2",
"pretty-quick": "^1.6.0",
"react-app-rewired": "^1.6.2",
"react-styleguidist": "^7.3.4"
},
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"collectCoverageFrom": [
"src/**/*.js",
"!src/index.js"
],
"coverageReporters": [
"text"
]
}
}
Я попытался изменить collectCoverageFrom, но он не работает.