Skip to content
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

Tests fail but gulp returns 0 #41

Open
drinckes opened this issue Apr 24, 2019 · 4 comments
Open

Tests fail but gulp returns 0 #41

drinckes opened this issue Apr 24, 2019 · 4 comments

Comments

@drinckes
Copy link

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:

var gulp = require('gulp');
var qunit = require('gulp-qunit');

gulp.task('test', () => {
  return gulp.src('./test.html').pipe(qunit());
});

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
...
[13:46:51] Took 75ms to run 203 tests. 202 passed, 1 failed.
[13:46:51] gulp-qunit: ✖ QUnit assertions failed in test.html

$ echo $?
0

gulp test still returns zero? How do I get gulp to return something else if the tests fail?

@jonkemp
Copy link
Owner

jonkemp commented Apr 26, 2019

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.

@jonkemp
Copy link
Owner

jonkemp commented Apr 26, 2019

You can also try node-qunit-phantomjs with gulp.

https://github.com/jonkemp/node-qunit-phantomjs

@drinckes
Copy link
Author

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;

@drinckes
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants