Getting the description of the parent statement in Mocha

Problem

Simple enough question, is there a way to get the description of the parent (it) statement in Mocha on Node.js?

So for example:

describe("Describe test", function(){
    it("Describe this specific test", function(){
        console.log(message); // Where message is "Describe this specific test"
    });
});

I mainly need this for writing log files automatically and accurately. Thanks for any help.

Problem courtesy of: whitfin

Solution

You could use the following

describe("Describe test", function(){
  it("Describe this specific test", function(){
    console.log('Title:', this._runnable.title);
  });
});
Solution courtesy of: robertklep

Discussion

Unfortunately, it doesn't seem possible: https://github.com/visionmedia/mocha/issues/620

Discussion courtesy of: dankohn

This recipe can be found in it's original form on Stack Over Flow.