-
Notifications
You must be signed in to change notification settings - Fork 41
chore(gulp): use Gulp async task support and Karma API properly #23
base: master
Are you sure you want to change the base?
Conversation
1. In the previous example, the Gulp's task complete callback was passed directly to the Server's constructor which is wrong. 2. There's new `deploy` task added to test and make sure that the Gulp's done callback is invoked with valid args. 3. Add PhantomJS browser to karma config. Closes #22
Hej Mistrzowie! Ktoś to zmerdżuje? |
👍 This is exactly what I needed to solve my issue with using the supplied examples in a CI environment. |
It still has problems. The server.start() kills the proccess when it ends (I don't know why) gulp.task('test', function(done) {
var server = new karma.Server({
configFile: __dirname + '/test/karma.config.js',
singleRun: true
});
server.on('run_complete', function (browsers, results) {
if (results.error || results.failed) {
done(new Error('There are test failures'));
}
else {
done();
}
});
server.start();
});
gulp.task('js', ['test'], function() {
return gulp.src('app/**/*.js')
.pipe(uglify())
.pipe(gulp.dest('public/js'));
}); The output (js task doesn't end): user@vm:/var/www/test# gulp js
[12:02:56] Using gulpfile /var/www/test/gulpfile.js
[12:02:56] Starting 'test'...
DEPRECATED: use your own version of lodash, this will go away in [email protected]
DEPRECATED: use your own version of lodash, this will go away in [email protected]
13 07 2016 12:02:56.898:INFO [karma]: Karma v1.1.1 server started at http://localhost:8080/
13 07 2016 12:02:56.901:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
13 07 2016 12:02:56.908:INFO [launcher]: Starting browser PhantomJS
13 07 2016 12:02:57.212:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#U1iVuy2DZhVyemxmAAAA with id 18916034
PhantomJS 2.1.1 (Linux 0.0.0): Executed 1 of 1 SUCCESS (0.047 secs / 0.001 secs)
.
PhantomJS 2.1.1 (Linux 0.0.0): Executed 1 of 1 SUCCESS (0.047 secs / 0.001 secs)
[12:02:57] Finished 'test' after 1.05 s
[12:02:57] Starting 'js'...
user@vm:/var/www/test# I had to run the test in a child gulp.task('test', function(done) {
var child_process = require('child_process');
child_process.exec('karma start test/karma.config.js', function (err, stdout){
gutil.log(stdout);
if (err) {
throw new Error('There are test failures');
}
else {
done();
}
});
}); |
I'll have a look at this PR once again. It's been created a while ago and there're some changes in Karma and my understanding of Gulp. |
The example in the README.md was precisely what I needed to fix a delayed-timeout issue; it'd be nice to get that merged so it's easier to find when debugging that issue. |
@danielpacak if I use your solution inside of a task chain no tasks will be executed after the karma task is finished, as |
No description provided.