-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Waiting for jasmine to end before going on #69
Comments
Hi, There's 2 parts to your question. The first is about Istanbul. I've used gulp-istanbul and gulp-jasmine together successfully using 2 patterns. The new one documented in their readme and the older one. Just replace mocha with jasmine and it should work correctly. The second part is about the gulpfile.js:
test.spec.js:
|
Hi, Thanks for looking into it. Best regards, |
Hi, I was able to reproduce the issue and found out that the 'end' event does not seem to be emitted when the stream is not returned. Not sure with your version of JS @jbblanchet, but maybe the stream is returned by default in your example. When I return the stream, the 'end' event is emitted. If I'm right - is this expected behaviour (return vs. no-return)? |
@JaycobA: Got it! Thanks for taking the time to reproduce You're right, when using a callback instead of returning the pipe it doesn't work. I must admit that I was a little stumped, and I still can't explain it, but I can rule out gulp-jasmine as the culprit. Try: gulp.task("default", function (cb) {
gulp.src("test.spec.js") // No gulp-jasmine
.on("end", function () {
console.log("We're done!");
cb();
});
}); and compare the behavior with: gulp.task("default", function () {
return gulp.src("test.spec.js") // No gulp-jasmine
.on("end", function () {
console.log("We're done!");
});
}); |
OK, investigated the issue a little further, and it seems that the behaviour changed changed with version 3.8 of Gulp. Run your test with gulp 3.7, and it should work fine. Not sure why that is, I'll log a bug in the gulp repo. |
Thanks for looking further into this issue. As going back to gulp 3.7 is no option, I tried using return, but it did not seem to help. What did help though, was adding a handler for the data event before the end handler. Although, the data event does nothing, the end event is emitted and the tests properly finish before going on. function testAll(callback) {
"use strict";
gulp.src('target/**/*Spec.js')
.pipe(jasmine())
.on('data', () => {})
.on('end', callback);
} |
Just wanted to let you know that we're still working on a potential solution. If you want to understand why you need to add a data handler, have a look at #71. |
Thanks @jbblanchet, I really appreciate your efforts in solving this. |
Sorry about that, forgot to come back here and let you know how we resolved the situation. There was a lot of discussion about the best approach, but in the end we went with adding a new event to the pipeline, which is This has been released in 2.4. I'll close the issue but feel free to discuss it here if there's still a problem. |
Thank you @jbblanchet. I'll apply this as soon as we update to 2.4. |
I have trouble figuring out how to wait for jasmine to be done. What I basically want to achieve is to have the tests be reported by Istanbul:
gulp.src('target/**/*Spec.js').pipe(jasmine()).pipe(istanbul.writeReports());
This does not work, as Instanbul starts writing reports while jasmine is still running. So I tried sequencing the tasks by introducing methods with callbacks like so:
My issue here is, when I use 'finish', the callback is invoked before jasmine is done. And wenn I use 'end', as suggested in another issue, the callback never gets invoked.
Any suggestion on what I am missing?
Thanks,
Stefan
Modules:
gulp-jasmine@2.3.0
jasmine@2.4.1
gulp@3.9.1
The text was updated successfully, but these errors were encountered: