导出Jest和ES6不采用的默认默认else路径 [英] Exports defaults else path not taken with Jest and ES6
问题描述
我在通过覆盖率100%的测试时遇到了问题.伊斯坦布尔说exports defaults Component
其他路径未采用.
I'm having issues to pass my tests with 100% coverage. Istanbul say that exports defaults Component
else path not taken.
因此,我在生成的伊斯坦布尔html文件中看到我的测试并不完全是100%.通常在语句和分支"选项卡中.
Because of that, I see in my generated html of istanbul that my tests are not completely at 100%. Mostly in the Statements and Branches tab.
我正在使用:
- 反应:15.4.0
- 笑话:17.0.2
- Webpack:1.12.11
有什么主意吗?
推荐答案
问题出在开玩笑的配置中,我们使用预处理器来解决某些导入问题:
The problem was in the jest configuration, we were using a preprocessor in order to resolve some imports:
在json包中,我们有以下内容:
In the package json we had this:
"transform": {
"^.+\\.js$": "<rootDir>/cfg/preprocessor.js"
},
此文件包含以下内容:
const babelJest = require('babel-jest');
require('babel-register');
const webpackAlias = require('jest-webpack-alias');
module.exports = {
process: function (src, filename) {
if (filename.indexOf('node_modules') === -1) {
src = babelJest.process(src, filename);
src = webpackAlias.process(src, filename);
}
return src;
}
};
我们更新到Jest v20
,并且还使用了来自Jest的模块解析器,在我们的package.json
中我们添加了:
We updated to Jest v20
and also use the module resolver from Jest, in our package.json
we added:
"moduleDirectories": [
"node_modules",
"src"
],
,并从package.json
和preprocessor.js
文件中删除了transform
配置.
and removed the transform
config from the package.json
and the preprocessor.js
file.
这篇关于导出Jest和ES6不采用的默认默认else路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!