webix - Cannot run multiple karma tests using suave server -
when run below tests individually (by commenting out) each test passes. however, when run tests xmlhttprequest uncaught exception. suave test server receives requests , logging shows no errors or problems:
var home_url = "http://localhost:3000/request"; it("should echo test request 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 test request 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); }); });
any ideas problem or how debug these tests?
to run code (git node , npm have installed):
git clone http://github.com/halcwb/genunitapp.git cd genunitapp git checkout failingserver scripts/run.sh
open second terminal
./build.sh clienttests
when down vote please explain, can improve question.
for running this, can nest ajax calls in before function , later on use promises (webix.ajax returns promise) in tests like:
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 test request 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 test request 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); }); });
please explain when down vote, try learn.
Comments
Post a Comment