Is it possible with Jest (Jasmine) to get the currently executed name of the test or describe inside the test?
Using Jasmine: How to get name of current test is not working anymore, at least with Jest.
e.g.
test('Error missing body', (done) => {
console.log('Currently executing: ' + REFERENCE_TO_TEST_NAME);
done();
});
Thanks
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}`);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With