Skip to content Skip to sidebar Skip to footer

Does Jasmine-node Offer Any Type Of "fail Fast" Option?

When I run a suite of jasmine tests from the command line I'd like some type of fail fast option so it stops at the first assertion error Does anything like this exist today?

Solution 1:

Just threw together jasmine-bail-fast to get this behavior.

npm install jasmine-bail-fast

Then before your first spec:

require('jasmine-bail-fast');
jasmine.getEnv().bailFast();

Hoping to get it merged to jasmine core then added as a flag to jasmine-node.

Solution 2:

I was able to monkey-patch jasmine for fast failures.

https://gist.github.com/btakita/4718081

Solution 3:

As far as I'm aware, the answer is "No". We get around this to some extent by splitting the tests into separate files and running them one by one, so it stops once it hits a file with a failing test.

Solution 4:

You can do it manually / artificially through a custom reporter. They seem to be working on that feature but issue is still open. Right now this is what I'm doing in jasmine-node:

functioninstallExitOnFail(runner)
{
    varSpecReporter = require('jasmine-spec-reporter')
    var exitOnFailReporter = newSpecReporter({displayStacktrace: true});
    var specDone = exitOnFailReporter.specDone
    exitOnFailReporter.specDone = function(result)
    {
        if(result.status === 'failed')
        {
            console.log(outpcolors.red('\nFailed test: ' + result.fullName +
                '\nReason: '+result.failedExpectations[0].message) +
                '\n' + result.failedExpectations[0].stackut);
            process.exit(1);
        }
        else
        {
            specDone.apply(exitOnFailReporter, arguments)
        }
    };
    runner.addReporter(exitOnFailReporter);
}

var jasmineRunner = newrequire('jasmine')();
installExitOnFail(jasmineRunner);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 99999999;
jasmineRunner.specFiles = [your specs files....];
jasmineRunner.execute();

Post a Comment for "Does Jasmine-node Offer Any Type Of "fail Fast" Option?"