breeze - Qunit tests are not working on visual studio 2012 as they work on browser -
i have developed spa application using knockout , breeze, have been using qunitjs unit testing works on browser project. have found plugin "chutzpah" vs2012, can work testing qunit, can check test cases , respond test though using breeze test cases includes:
creating, deleting, modifying entities on client side
save changes on server side using breeze controller sqlserver
here problem breeze test cases fails when testing in chutzpah because not getting client side information like(metadata/ controllermethods) called browser through url defined in breezeconfig. question how can perform unit test on breeze on server side real unit test cases do. suggestions using new plugins or libraries can make me unit testing of breeze welcome
here snippet testing project:
asynctest("can save nothing", function () { expect(1); newem().savechanges() .then(function(saveresult) { equal(saveresult.entities.length, 0, 'succeeded in saving nothing'); }) .catch(handlefail).finally(start); }); asynctest("can save new customer entity", function () { expect(1); // create , initialize entity save var em = newem(); var customer = em.createentity('customer', { customerid: newguidcomb(), companyname: 'test1 ' + new date().toisostring() }); em.savechanges() .then(function (saveresults) { ok(!!saveresults.entities[0], ' should have saved new customer customerid ' + customer.getproperty('customerid')); }) .catch(handlefail).finally(start); }); asynctest("can modify own customer entity", function () { expect(2); var timestamp = new date().toisostring(); var em = newem(); var customer = em.createentity('customer', { customerid: newguidcomb(), companyname: "test2a " + timestamp }); em.savechanges().then(modifycustomer).fail(handlesavefailed).fin(start); function modifycustomer(saveresults) { var saved = saveresults.entities[0]; ok(saved && saved === customer, "save of added customer should have succeeded"); customer.companyname("test2m " + timestamp); return em.savechanges() .then(confirmcustomersaved); } function confirmcustomersaved(saveresults) { var saved = saveresults.entities[0]; ok(saved && saved === customer, "save of modified customer, '{0}', should have succeeded" .format(saved && saved.companyname())); } });
the short answer set tests server communication not required. capture metadata can load script before run tests. create mock data in breeze query local entitymanager instead of server.
and, of course, should separate business logic of application (the kind needs lot of testing) server-communication bits.
Comments
Post a Comment