Get currently executed describe/test name

From this thread:

console.log(expect.getState().currentTestName);

Worked for me.


The tests are supposed to contain only the basic code for your test: Arrange / Act / Assert, so it's not a good practice to introduce this kind of code at this place. But if you want to log the currently running test, you can use the custom_reporter API: https://jasmine.github.io/2.1/custom_reporter.html

You can get the same result that you expect by adding this code:

jasmine.getEnv().addReporter({
  specStarted: function(result) {
    console.log(`Spec name: ${result.fullName}, description: ${result.description}`);
  }
});

Tags:

Jasmine

Jestjs