26

現在実行中のテストの名前を取得する方法はありますか?

一部の (非常に単純化された) コードが説明に役立つ場合があります。"test1" / "test2"への呼び出しでの重複を避けたいperformTest:

describe("some bogus tests", function () {

    function performTest(uniqueName, speed) {
        var result = functionUnderTest(uniqueName, speed);
        expect(result).toBeTruthy();
    }

    it("test1", function () {
        performTest("test1", "fast");
    });

    it("test2", function () {
        performTest("test2", "slow");
    });
});

更新 必要な情報が次の場所にあることがわかります。

jasmine.currentEnv_.currentSpec.description

またはおそらくより良い:

jasmine.getEnv().currentSpec.description
4

3 に答える 3

14
jasmine.getEnv().currentSpec.description
于 2012-10-10T07:47:30.517 に答える