【问题标题】:remap istanbul when using typescript AND babel使用打字稿和 babel 时重新映射伊斯坦布尔
【发布时间】:2016-11-13 13:32:04
【问题描述】:
我正在尝试使用 remap istanbul 来获取我的 TypeScript 项目的代码覆盖率。但是,因为我使用的是 async/await 并且 TypeScript 还不支持将该代码转换为 ES5,所以我也使用 Babel 来完成这项工作。所以基本上我的 typescript 代码由 TypeScript 编译器转译为 ES6,然后使用 Babel 转译为 ES5。
现在,当我尝试生成覆盖率报告时,它无法加载由 TypeScript 生成的 JavaScript 文件,因为该文件从未创建过(因为我使用的是 gulp 并且我直接通过管道传输它)。最好的设置方法是什么?
【问题讨论】:
标签:
javascript
typescript
babeljs
remap-istanbul
【解决方案1】:
只有伊斯坦布尔 1.x 做得好。
来自this repository:
{
"name": "sample-babel-node",
"version": "1.0.0",
"description": "Sample project to demonstrate source mapped coverage reports with istanbul",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "babel-node ./node_modules/istanbul/lib/cli.js cover ./test/index.test.js"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/istanbuljs/sample-babel-node.git"
},
"author": "",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/istanbuljs/sample-babel-node/issues"
},
"homepage": "https://github.com/istanbuljs/sample-babel-node#readme",
"dependencies": {
"babel-cli": "^6.2.0",
"babel-preset-es2015": "^6.1.18"
},
"devDependencies": {
"istanbul": "^1.0.0-alpha.2"
}
}
还可以查看this git issue,还有更多内容(gulp、grunt 等)。