我将mocha与伊斯坦布尔结合使用,我开始使用TypeScript。结合ts-node
运行mocha测试不是问题。问题在于让伊斯坦布尔与TypeScript合作。 Gulp环境中是否有任何工具可以使其工作?
伊斯坦布尔任务
//This task was written before typescript
//Paths is a JSON object which contains all paths
//ISparta to convert it to ES5 compatible code
gulp.task('istanbul', () => {
return gulp.src([paths.source.ecmascript])
.pipe(istanbul({
includeUntested: true,
instrumenter: isparta.Instrumenter
}))
.pipe(istanbul.hookRequire())
.pipe(gulp.dest(paths.coverage));
});
摩卡任务
//Currently working version with typescript
require('ts-node/register');
gulp.task('mocha', [], () => {
return gulp.src([paths.test], {read: false})
.pipe(mocha({
reporter: 'spec',
timeout: 5000,
bail: false
}))
/*
.pipe(istanbul.writeReports({
reporters: ['lcov', 'json', 'text-summary']
}))
*/
.once('error', () => {
process.exit(1);
})
.once('exit', () => {
process.exit();
})
.on('error', gulpUtil.log);
});