尝试让gulp-mocha对JavaScript文件运行mocha测试并使用nyan cat reporter返回结果。当我运行命令时,我收到以下错误
'mocha' errored after 244 ms
ReferenceError in plugin 'gulp-mocha'
Message:
document is not defined
这是我的Gulpfile.js中的任务
var gulp = require('gulp');
var mocha = require ('gulp-mocha');
gulp.task('mocha', function () {
return gulp.src(jsSources, {read: false})
.pipe(mocha({reporter: 'nyan'}));
});
我是否需要安装' nayn'记者作为依赖还吗?
答案 0 :(得分:0)
不,您不需要将其作为依赖项安装。试试这个:
var gulp = require('gulp');
var mocha = require('gulp-mocha');
gulp.task('default', function () {
gulp.watch(['./mocha/*'], ['mocha']);
});
gulp.task('mocha', function(){
return gulp.src('./mocha/*', {read: true})
.pipe(mocha({reporter: 'nyan'}));
});