How to get current specification handle from beforeEach in jasmine test?

I understand that the currentSpec link is no longer available in beforeEach from jasmine 2.0.0 (Link: https://github.com/pivotal/jasmine/issues/492 )

Is there an alternative for finding the current Spec or Suite (subpackage) in beforeEach?

Thanks, VJ.

+4
source share
1 answer

You can use the reporter

describe("outer", function() {

  var specDescription, specFullName;

  (function() {
    jasmine.getEnv().addReporter({
      suiteStarted: function(result) {
        specDescription = result.description;
        specFullName = result.fullName;
      }
    });
  })();

  beforeEach(function() {
    console.debug(specDescription);
    console.debug(specFullName);
  });


  describe("test1", function() {
    it("bla bla", function() {});
  });
  describe("test2", function() {
    it("bla bla", function() {});
  });
}
0
source

Source: https://habr.com/ru/post/1532891/


All Articles