您好我正在尝试使用Jest + Enzyme来测试我的反应成分。我没有使用创建反应应用程序,所以我发现错误我变得非常奇怪。有谁知道我在做错了什么?
这是错误:
开箱即用,Create React App仅支持覆盖这些Jest选项:
•collectCoverageFrom •coverageReporters •coverageThreshold •snapshotSerializers。
Create React App目前不支持package.json Jest配置中的这些选项:
•setupTestFrameworkScriptFile
如果您希望覆盖其他Jest选项,则需要从默认设置中弹出。您可以通过运行npm run eject来执行此操作,但请记住这是一个单向操作。您也可以使用Create React App提出问题,以讨论支持更多开箱即用的选项。
这是我的test-setup.js
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';
configure({ adapter: new Adapter() });
这是我的package.json
{
"name": "duplo-plugin-starter-react",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"doc": "docs"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/test-setup.js"
},
"scripts": {
"test": "react-scripts-ts test --env=jsdom",
"build": "webpack",
"start": "webpack-dev-server --progress --inline"
},
"repository": {
"type": "git",
"url": "git@github.corp.dyndns.com:vcharlesthompson/duplo-plugin-starter-react.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/react": "^16.0.18",
"@types/react-dom": "^16.0.2",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"source-map-loader": "^0.2.3"
},
"devDependencies": {
"@types/enzyme": "^3.1.1",
"@types/jest": "^21.1.5",
"awesome-typescript-loader": "^3.2.3",
"css-loader": "^0.28.7",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"react-addons-test-utils": "^15.6.2",
"react-scripts-ts": "^2.8.0",
"react-test-renderer": "^16.0.0",
"style-loader": "^0.19.0",
"typescript": "^2.5.3",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.3"
}
}