jasmineDone reporter callback not working with jasmine-npm

497 views
Skip to first unread message

Ben Loveridge

unread,
Feb 17, 2015, 2:36:01 PM2/17/15
to jasmi...@googlegroups.com
I’m trying to use jasmine-npm along with some custom reporters, but it looks like the `jasmineDone` callback isn’t being called for them. I’m not sure if it is because the reporter is registered in the wrong place or what, but I could find very little documentation on using jasmine-npm and what I’ve tried so far isn’t working.

There’s a runnable example you can look at (http://runnable.com/VOOTD1ziRwpp5ULs/jasmine-npm-reporters-test-for-node-js), but here’s the basic gist of what I’ve done:

1. I’m using the default spec/support/jasmine.json which loads helpers from helpers/**/*.js
2. I’ve created an extremely simple spec file including a single describe with a single it (basicSpec.js)
3. I created helpers/reporters.js which adds a very simple reporter that simply logs out a statement each time the various callbacks are invoked: jasmineStarted, suiteStarted, specStarted, specDone, suiteDone, jasmineDone

All the callbacks are correctly called *except* jasmineDone, which never seems to be called at all.  For fun, I have tried modifying the included console_reporter.js and inserting a log statement into its jasmineDone callback, which *is* correctly called.

Is there a more correct way of adding custom reporters? Am I doing something else wrong? Or is this a bug in how jasmine-npm is working?

At the end of the day, I’m trying to get this working because until I figure out what is going wrong and solve it I’m not sure the various reporters included in jasmine-reporters are working correctly when used via jasmine-npm directly. They work fine when used via its own PhantomJS runner, inside protractor using “framework:jasmine2”, jasmine-node, but so far I haven’t been able to make them work with vanilla jasmine-npm. And I really want to :)

Thanks in advance,
Ben

Gregg Van Hove

unread,
Feb 27, 2015, 7:15:40 PM2/27/15
to jasmi...@googlegroups.com
We've made some recent changes to jasmine-npm that should allow adding a reporter from your helpers directory to have all of its callbacks called before the process is exited. There is now a reporter specifically for determining exit code status, that is added at the last minute right before the suite is executed, so anything loaded in helpers should be added before it. This hasn't been released yet, though. If you have a chance to try out master, I think it should work for you.

-Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at http://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Ben Loveridge

unread,
Feb 28, 2015, 3:48:09 PM2/28/15
to jasmi...@googlegroups.com
Thanks Gregg, I've updated the runnable example to use master and it is now working as you indicated it should. I've confirmed it also works with more complex reporters like the jasmine-reporters JUnitXmlReporter which writes results to the FS and it also works as expected. Thanks for the update, both in terms of the code and the thread here!

What version of jasmine-npm do you expect this to land in -- will it be 2.2.2 or 2.3?

Thanks again.
Ben

Gregg Van Hove

unread,
Mar 1, 2015, 5:18:39 PM3/1/15
to jasmi...@googlegroups.com
It will be in the next release, but there is still some other stuff we need to work on with helpers before we're ready to release. Not sure yet what the actual version number will be yet.

-Gregg

Michael Lampi

unread,
Feb 26, 2016, 12:01:39 PM2/26/16
to Jasmine
I have seen similar behavior with the latest Jasmine (downloaded and installed today). If you have two reporters defined (jasmine-spec-reporter) and another custom reporter, then both reporters and all their entry points are called as expected if all of the specs are successful or pending.

However, if the specs have a failure, then jasminDone is only called for the first reporter.

Any idea as to why this is the case?

Thanks!

Michael

Gregg Van Hove

unread,
Feb 26, 2016, 1:49:57 PM2/26/16
to jasmi...@googlegroups.com
How are your reporters being added? It's possible that if one is added after the suite starts running, it will be invoked after the exit_code reporter is added and that's why it isn't getting called. Adding a reporter at this time also means that it will have missed at least one, if not more, events from the suite running, so you probably want to get it added earlier. The ideal location would be in a helper file that Jasmine will load before loading and running your specs.

Hope this helps. Thanks for using Jasmine!

-Gregg

Michael Lampi

unread,
Feb 26, 2016, 2:33:52 PM2/26/16
to jasmi...@googlegroups.com
Hi Gregg,

I have tried several methods for adding the reporter. The one that works the best for me so far is to have the reporter in a 'require' line included at the very beginning of the spec file. This is definitely run before any of the specs.

Note that I instrumented my reporter with debug output for each of the documented reporter entry points, and each entry point is called when expected when the specs do not have a failure. It is only when a failure occurs that the jasmineDone entry point is not called. All of the other entry points are called as would be expected.

Best regards,

Michael Lampi

--
You received this message because you are subscribed to a topic in the Google Groups "Jasmine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jasmine-js/vhJC2SfBk-s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jasmine-js+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages