logging - Execute code after Jasmine test failure -


is possible if jasmine test fails? juxtaposed aftereach() executes after it() regardless of outcome, i'm looking way execute code after it() has failed expectation.

this question not angular-specific, in scenario testing angular service outputs debug messages using $log. don't want clutter console tests successful, show additional information failing tests.

describe("myservice", function() {     var myservice, $log;      beforeeach(function() {         inject(function (_myservice_, _$log_) {             myservice = _myservice_;             $log = _$log_;         });     });      aftereach(function () {         if (/* test failed */) {             //console.log($log.debug.logs);         }     });      it("should output debug logs when fails", function() {         //do myservice put message in $log         expect(false).tobe(true);     }); }); 

i'm running jasmine 2.2.0.

edit: here's simple fiddle shows jasmine 1.3 jasmine.getenv().currentspec solution no longer working.

here's hack re-enable jasmine.getenv().currentspec in jasmine 2 (sort of, result isn't full spec object, contains id, description, fullname, failedexpectations, , passedexpectations):

jasmine.getenv().addreporter({     specstarted(result) {         jasmine.getenv().currentspec = result;     },     specdone() {         jasmine.getenv().currentspec = null;     } }); 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -