Gulp: tube typescript outlet in mocha

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})
        // gulp-mocha needs filepaths so you can't have any plugins before it 
        .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?

+4
source share
1 answer

typescript gulp.dest, . .

gulp.src(['./test/**/*.ts', './typings/tsd.d.ts'])
  .pipe(typescript())
  .pipe(gulp.dest(''))
  .pipe(mocha());
0

Source: https://habr.com/ru/post/1623382/


All Articles