Javascript Jest,如何忽略特定文件夹的测试覆盖率?
在react项目中,我有一个根Javascript Jest,如何忽略特定文件夹的测试覆盖率?,javascript,testing,jestjs,Javascript,Testing,Jestjs,在react项目中,我有一个根/styles文件夹,其中包含样式化组件的各种样式对象。我不希望这些文件显示在覆盖率测试中 我试着像这样隐藏它们,但当我运行npm run coverage时,它们仍然会出现 package.json 将其添加到您的配置(package.json): modulePathIgnorePatterns:[“directoryNameToIgnore”] 或: modulePathIgnorePatterns:[“/dist/”] 以及: coveragePathIg
/styles
文件夹,其中包含样式化组件的各种样式对象。我不希望这些文件显示在覆盖率测试中
我试着像这样隐藏它们,但当我运行npm run coverage
时,它们仍然会出现
package.json
我所需要的就是package.json中的这个
"coveragePathIgnorePatterns": [
"<rootDir>/styles/"
],
那没用,但我只是想办法。。。立即发布
{
"env": {
"development": {
"presets": [
"next/babel",
"@zeit/next-typescript/babel"
],
"plugins": [
["styled-components", {"ssr": true, "displayName": true}],
["@babel/plugin-proposal-decorators", {"legacy": true}],
["istanbul",{"exclude": ["styles/*.js"]}]
]
},
"production": {
"presets": [
"next/babel",
"@zeit/next-typescript/babel"
],
"plugins": [
["styled-components", {"ssr": true, "displayName": true}],
["@babel/plugin-proposal-decorators", {"legacy": true}]
]
},
"test": {
"presets": [
"@babel/preset-typescript",
["next/babel", {"preset-env": { "modules": "commonjs" }}]
],
"plugins": [
["styled-components", { "ssr": true, "displayName": true }],
["@babel/plugin-proposal-decorators", { "legacy": true }],
["babel-plugin-sass-vars"]
]
}
}
}
"coveragePathIgnorePatterns": [
"<rootDir>/styles/"
],
["istanbul",{"exclude": ["styles/*.js"]}]