Callback for jasmine testing complete

1,207 views
Skip to first unread message

Anthony Mann

unread,
Sep 28, 2011, 7:07:32 AM9/28/11
to Jasmine
Hi,

Just a quick one, is there a 'recommended' way of detecting or
receiving a callback when the tests are complete?

It would be nice if i could do something along the lines of:

jasmineEnv.execute(function(){
console.log('tests completed!');
});

Rather than initially hacking away i thought i would ask if this has
been considered already.

Thanks in advance

Ben Loveridge

unread,
Sep 28, 2011, 8:01:15 PM9/28/11
to jasmi...@googlegroups.com
Jasmine has hooks that allow the creation of custom reporters. Take a
look at the jasmine-reporters project on github for a couple examples
including a console reporter.

https://github.com/larrymyers/jasmine-reporters

--
Ben Loveridge

> --
> You received this message because you are subscribed to the Google Groups "Jasmine" group.
> To post to this group, send email to jasmi...@googlegroups.com.
> To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.
>

Jordan Black

unread,
Mar 21, 2014, 12:00:34 PM3/21/14
to jasmi...@googlegroups.com
Looks like the currentRunner() method is no longer available in Jasmine 2.0.  I'm more interested in what used to be jasmine.getEnv().currentRunner().results().failedCount().  Is there any way to get this information in Jasmine 2?


On Wednesday, June 27, 2012 11:37:26 PM UTC-4, anonymous coward wrote:
Hello, I know this is late but I thought I'd add this for anyone interested:

The jasmine.Env() object has the method "currentRunner()".  this returns the runner the env is going to use to execute the tests.

The jasmine.Runner() object has the method finishCallback().  Overriding this method completely breaks functionality, but I added a function which intercepts this call so that I could hook into the callback.  Like this:

var oldCallback = jasmineEnv.currentRunner().finishCallback;
jasmineEnv.currentRunner().finishCallback = function () {
oldCallback.apply(this, arguments);
$("body").append( "<div id='_test_complete_signal_'></div" );
};
jasmineEnv.execute();

You shouldn't override the finishCallback completely because that breaks the HTMLReporter; who knows what else.  Hence the first call "oldCallback.apply(this, arguments);"

I suggest using this over reporters, because they don't have an 'all done' callback for when *everything* finishes.  
Reply all
Reply to author
Forward
0 new messages