2

Twitter Boostrap モーダル ダイアログをカバーする Jasmine テストを作成しようとしています。デバッガー行がコメントアウトされている場合、テストは失敗します。デバッガーによって処理が一時停止され、続行すると合格します。モーダルダイアログは、期待呼び出しの時点でDOMにまだないため、Bootstrapモーダルの遷移が問題を引き起こしていると思います。

テスト中にトランジションを無効にするにはどうすればよいですか?

ありがとう

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")
    })
})

ジャレッドに感謝します。あなたのソリューションはうまくいきました! これが私の作業テストです:

    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")
            })
        })      
    })
4

1 に答える 1

3
于 2013-09-23T17:29:57.760 に答える