I want to add a mocha test to a TypeScript project. In gulpfile.jsI am the gulp pipe - typescript and gulp -mocha tegether:
gulp.src(['./test/**/*.ts', './typings/tsd.d.ts'])
.pipe(typescript())
.pipe(mocha());
Mocha reports an error Error: Cannot find module '.../myproject/test/case1.js'.
A google search, all the examples I found save the transpiler TypeScript output to temporary files, and then run using mocha. I also noticed that the gulp -mocha document says: "there are no plugins in front of it":
gulp.task('default', function () {
return gulp.src('test.js', {read: false})
.pipe(mocha({reporter: 'nyan'}));
});
However, one advantage of gulp is the use of a stream to skip temporary files. How can I pass the transpiler output to mocha? Or is it impossible for mocha?
source
share