0

以下のテストを (コメントアウトして) 個別に実行すると、各テストに合格します。ただし、すべてのテストを実行すると、XmlHttpRequest のキャッチされない例外が発生します。suave テスト サーバーはリクエストを受信し、ログにはエラーや問題は示されません。

var HOME_URL = "http://localhost:3000/request";

it("should echo the test request with response", function (done) {
    var test = { act: 'test1', qry: {} };

    var promise = webix.ajax().post(HOME_URL, JSON.stringify(test));

    console.log('test1');
    promise.then(function (resp) {
        expect(resp.json().succ).to.be(true);
        done();
    }).fail(function (err) {
        done();
        throw(err);
    });

});


it("should echo the test request with response 2", function (done) {
    var test = { act: 'test2', qry: {} };

    var promise = webix.ajax().post(HOME_URL, JSON.stringify(test));

    console.log('test2');
    promise.then(function (resp) {
        expect(resp.json().succ).to.be(true);
        done();
    }).fail(function (err) {
        console.log('echo test error', app.util.inspect(promise));
        done();
        throw(err);
    });

});

問題が何であるか、またはこれらのテストをデバッグする方法はありますか?

自分でコードを実行するには (git ノードと npm をインストールする必要があります):

git clone http://github.com/halcwb/GenUnitApp.git cd GenUnitApp git checkout failingServer scripts/run.sh

2 番目のターミナルを開く

./build.sh clienttests

反対票を投じたら、説明してください。質問を改善できます。

4

1 に答える 1

0

これに遭遇した人は、前の関数で ajax 呼び出しをネストし、後で次のようなテストで promise (webix.ajax が promise を返す) を使用できます。

var HOME_URL = "http://localhost:3000/request";
var test1, test2;

before(function () {
    var req = { act: 'test1', qry: {}};

    test1 = webix.ajax().post(HOME_URL, JSON.stringify(req));
    req.act = "test2";
    test2 = webix.ajax().post(HOME_URL, JSON.stringify(req));
});

it("should echo the test request with response", function (done) {
    var promise = test1;

    promise.then(function (resp) {
        expect(resp.json().succ).to.be(true);
        done();
    }).fail(function (err) {
        done();
        throw(err);
    });

});


it("should echo the test request with response 2", function (done) {
    var promise = test2;

    promise.then(function (resp) {
        expect(resp.json().succ).to.be(true);
        done();
    }).fail(function (err) {
        done();
        throw(err);
    });

});

反対票を投じるときに説明してください、私は学ぼうとしています。

于 2016-07-19T13:58:26.053 に答える