-
Notifications
You must be signed in to change notification settings - Fork 36
Passing a glob to gulp-karma watches individual files and does not catch newly added files #3
Comments
:( |
@chrisabrams, I'll be at you soon with a workaround to turn that frown upside down. |
Man. I want this so bad. |
Why not use the gulp.watch method instead and use the action "run" ? my guess is that it should work |
The problem lies in the fact that @koblass, that would involve an additional task for starting the Karma server, and it was getting a bit ugly when I tried that route before. Will reconsider it, but it's looking like this will end up gulp-friendly and avoid using gulp's |
@lazd This may be related to floatdrop/gulp-watch#16 (comment) |
+1 |
Here's what I've found: I can't get the runner to recognize new files if the server has already been started. In order to make it happen, the server needs to be started/killed on every test run. The following is currently possible: var gulp = require('gulp');
var karma = require('gulp-karma');
// Include order
// Could be globs instead
var includeOrder = [
'client/scripts/todo/todo.js',
'client/scripts/todo/todo.polyfills.js',
'client/scripts/todo/todo.util.js',
'client/scripts/todo/todo.App.js'
];
// Add the tests to the include order
// Uses a glob to catch all tests
var testIncludeOrder = includeOrder.concat(['test/client/*.js']);
// Run tests once
gulp.task('test', function() {
// The glob is evaluated again, so new files are picked up
return gulp.src(testIncludeOrder)
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}));
});
gulp.task('default', function() {
// Run on start
gulp.run('test');
// Run on change
// This watches on the glob, not the individual files
gulp.watch(testIncludeOrder, function() {
return gulp.run('test');
});
}); This is less than ideal. I'll keep looking for a workaround and will investigate into whether Karma can be patched to fix this, but for now, the above workaround does get the job done. |
Idea, probably not a good one: you can set Just read the previous commend by @lazd, this is more or less the same suggestion. |
|
If you pass a glob, say
tests/**/*.js
, then add files totests/
, they are not included in subsequent test runs as the globs are resolved before being passed to Karma's watch mechanism.The text was updated successfully, but these errors were encountered: