ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 在 gulp 中运行 Mocha 测试 ### 运行所有的测试用例 ``` // npm install gulp gulp-mocha var gulp = require('gulp'); var mocha = require('gulp-mocha'); gulp.task('default', function() { return gulp.src(['test/test-*.js'], { read: false }) .pipe(mocha({ reporter: 'spec', globals: { should: require('should') } })); }); ``` ### 在文件改动时候运行 mocha 测试用例 ``` // npm install gulp gulp-mocha gulp-util var gulp = require('gulp'); var mocha = require('gulp-mocha'); var gutil = require('gulp-util'); gulp.task('mocha', function() { return gulp.src(['test/*.js'], { read: false }) .pipe(mocha({ reporter: 'list' })) .on('error', gutil.log); }); gulp.task('watch-mocha', function() { gulp.watch(['lib/**', 'test/**'], ['mocha']); }); ```