Twitter bootstrap 禁用Jasmine测试的引导转换

Twitter bootstrap 禁用Jasmine测试的引导转换,twitter-bootstrap,jasmine,Twitter Bootstrap,Jasmine,我正试图编写一个Jasmine测试来覆盖Twitter Boostrap模式对话框。当调试器行被注释掉时,测试失败。当调试器暂停处理并且我继续时,它将通过。我认为引导模式中的转换导致了这个问题,因为在我调用expect时,模式对话框还不在DOM中 如何在测试期间禁用转换 谢谢 describe("test dialog", function(){ it("when cancel button is clicked", function() { spyOn(MyTestOb

我正试图编写一个Jasmine测试来覆盖Twitter Boostrap模式对话框。当调试器行被注释掉时,测试失败。当调试器暂停处理并且我继续时,它将通过。我认为引导模式中的转换导致了这个问题,因为在我调用expect时,模式对话框还不在DOM中

如何在测试期间禁用转换

谢谢

describe("test dialog", function(){
    it("when cancel button is clicked", function() {
        spyOn(MyTestObj, 'myMethod')

        $("#cancelButton").click();

        debugger;

        expect($(".bootbox-body")).toHaveText("Are you sure you want to cancel?")

        $('.modal-footer button[data-bb-handler="Yes"]').click();

        expect(MyTestObj.myMethod).toHaveBeenCalledWith("123")
    })
})
谢谢Jarred,你的解决方案非常有效!这是我的工作测试:

    describe("test dialog", function(){
        it("when cancel button is clicked", function() {
            spyOn(MyTestObj, 'myMethod')

            $("#cancelButton").click();

            waitsFor(function() {
                return $(".bootbox-body").is(":visible");
            }, "Element did not show up", 1000);

            runs(function () {
                expect($(".bootbox-body")).toHaveText("Are you sure you want to cancel?")
                $('.modal-footer button[data-bb-handler="Yes"]').click();

                expect(MyTestObj.myMethod).toHaveBeenCalledWith("123")
            })
        })      
    })

您可以使用
waitsFor
jasmine方法,后跟
runs
block():


$('.modal页脚按钮[data bb handler=“Yes”]')。单击()

waitsFor(function() {
    return $(".bootbox-body").is(":visible");
}, "Element did not show up", 1000);

runs(function () {
    expect(MyTestObj.myMethod).toHaveBeenCalledWith("123")
})