开发者

Why would false not be defined in jasmine?

I'm using jasmine in conjunctio开发者_JAVA百科n to Js-test-driver using an adapter to connect them both.

I've got the following test case:

describe("Undefined false", function(){
    beforeEach(function(){
        var undefFalse = false;
    });

    it("should return a defined value", function(){
        expect(this.undefFalse).toBeDefined();
    });

    it("should return false", function(){
        expect(this.undefFalse).toBeFalsy();
    });
});

Whereas the second test succeeds as expected, the first fails with the following error:

Undefined false test.test that it should return a defined value failed (0,00 ms): AssertError: Expected undefined to be defined.

Why is it that false should be undefined?


I don't know much about jasmine but this:

var undefFalse = false; // local variable

this.undefFalse; // property of an object(?)

will obviously not work.

Make sure to either get rid of the this. in the asserts, or set undefFalse on the correct object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜