Open drinckes opened 5 years ago
Try updating to the latest, 2.0.3 which was just published.
You can also listen to the gulp-qunit.finished
event and check if it passed or failed there.
You can also try node-qunit-phantomjs with gulp.
Thanks @jonkemp - I tried to listen to the gulp-qunit.finished
event (using .on()
?) but couldn't get it to work. I'm pretty sure I tried 2.0.3 but I ended up switching to phantomjs, and forcing it to throw an error on test failure:
var gulp = require('gulp');
var phantom = require('node-qunit-phantomjs');
function test(callback) {
phantom('./test.html', {'verbose': true}, (result) => {
// Called with 0 for successful test completion, 1 for failure(s).
if (result === 0) {
callback();
} else {
callback(new Error('tests failed'));
}
});
}
exports.test = test;
Duh just noticed your comment about 2.0.3 just being released. As I don't possess a time machine I must have been using 2.0.2.
I'm not sure if this is a gulp-qunit problem, a gulp problem, or I'm holding it wrong. :-)
My gulpfile is pretty standard:
I'm using gulp 4.0.1, gulp-qunit 2.0.2. If I run my tests, and the tests pass, then gulp returns 0. But if I edit my tests to force them to fail:
gulp test
still returns zero? How do I get gulp to return something else if the tests fail?