Jasmine2: 現在の仕様名を取得する 質問する

Jasmine2: 現在の仕様名を取得する 質問する

Jasmine 1.3 では、現在の仕様とスイート名を取得するためのこのオプションがありました。

describe("name for describe", function () {
    it("name for it", function () {
        console.log(this.suite.getFullName()); // would print "name for describe"
        console.log(this.description); // would print "name for it"
    });
});

これは Jasmine 2.x では動作しません。取得する方法を知っている人はいますか?

ありがとう。

ベストアンサー1

新しい Jasmine レポーターを追加し、各仕様で N 変数を定義せずに仕様名を取得します。お役に立てれば幸いです。ありがとうございます。

var reporterCurrentSpec = {
     specStarted: function(result) {
         this.name = result.fullName;
     }
 };
jasmine.getEnv().addReporter(reporterCurrentSpec);

おすすめ記事