2016-01-08 15 views
4

我想將摩卡測試添加到TypeScript項目中。在gulpfile.js我管一飲而盡,打字稿及吞掉,摩卡tegether:gulp:管道打印稿輸出到摩卡

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

摩卡報告錯誤Error: Cannot find module '.../myproject/test/case1.js'

在Google上搜索到的,我發現的所有例子都是將typescript轉譯器輸出保存到臨時文件中,然後使用mocha運行。我還注意到,一飲而盡,摩卡文檔中它說:「你不能收到任何插件」:

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'})); 
}); 

然而,一飲而盡的一個好處是使用流省略臨時文件。我怎樣才能將翻譯輸出管理到摩卡?或者摩卡咖啡不可能?

回答

0

在使用gulp.dest將輸入文件編譯器輸出傳輸到目標位置之前,您不會有mocha的輸出文件來運行測試。以下將根據我的測試工作。

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