我正在尝试设置gulp watch任务以在一组文件夹下运行所有测试,我可以获得成功运行的gulp任务:
[10:20:15] Finished 'karma' after 5.86 s
[10:20:15] Starting 'default'...
[10:20:15] Finished 'default' after 9.45 ms
但没有任何测试通过的通知?
这是我的karma.config:
var webpack = require("webpack"),
path = require("path");
module.exports = function (config) {
config.set({
basePath: "",
frameworks: ["jasmine"],
files: [
"./App/src/tests/**/*.js"
],
preprocessors: {
"./App/src/tests/**/*.js": ["webpack"]
},
webpack: {
module: {
loaders: [
{ test: /\.js$/, loader: "jsx-loader" }
]
},
plugins: [
new webpack.ResolverPlugin([
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
])
],
resolve: {
root: [path.join(__dirname, "./bower_components"), path.join(__dirname, "./src")]
}
},
webpackMiddleware: {
noInfo: true
},
plugins: [
require("karma-webpack"),
require("karma-jasmine"),
require("karma-chrome-launcher")
],
reporters: ["dots"],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ["Chrome"],
singleRun: false
});
};
这是我的karma.js:
var gulp = require('gulp');
var karma = require('gulp-karma');
function handleError(err) {
this.emit('end');
}
gulp.task('karma', function() {
return gulp
.src('./App/src/tests/**/*.js')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on("error", handleError);
});
Gulpfile:
var gulp = require('gulp'),
requireDir = require('require-dir');
requireDir('./gulp-tasks');
gulp.task('default', ['browserify','css','karma'], function () {
gulp.watch('../App/src/**/*.js', ['browserify']);
gulp.watch('../App/src/**/*.css', ['css']);
gulp.watch('../App/src/tests/**/*.js', ['karma']);
});