javascript - Does jasmine-node offer any type of "fail fast" option? - Stack Overflow

When I run a suite of jasmine tests from the mand line I'd like some type of fail fast option so i

When I run a suite of jasmine tests from the mand line I'd like some type of fail fast option so it stops at the first assertion error

Does anything like this exist today?

When I run a suite of jasmine tests from the mand line I'd like some type of fail fast option so it stops at the first assertion error

Does anything like this exist today?

Share Improve this question asked Jul 19, 2012 at 14:17 Toran BillupsToran Billups 27.4k41 gold badges158 silver badges272 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

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.

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

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

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.

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:

function installExitOnFail(runner)
{
    var SpecReporter = require('jasmine-spec-reporter')
    var exitOnFailReporter = new SpecReporter({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 = new require('jasmine')();
installExitOnFail(jasmineRunner);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 99999999;
jasmineRunner.specFiles = [your specs files....];
jasmineRunner.execute();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743949819a4534736.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信