
Originally Posted by
jjathman
My group has just started using Ext and are wondering if anyone has some good strategies for testing ext based applications? Currently we use JSUnit and Selenium to test our pages, which works fine on traditional pages with a relatively static DOM, but with all the dynamic content created by Ext our tools don't seem to work quite as well.
What is everyone else out there using to test their applications? I'm especially curious about how to mock out the server dependencies on the Ajax requests. Thanks.
By the way, we love Ext, it's an amazing framework.
I use JSunit to mock the server responses.
JSUnit (SVN version) contains a mockRequest object - checkout Edward Hieatts blog. You may also want to look at MockJS for additional object mocking.
In your page setup replace Exts xhr object with the mock version like so:
PHP Code:
mockRequest = createXmlHttpRequest();
Ext.lib.Ajax.createXhrObject = function(transactionId) {
return{conn:mockRequest, tId:transactionId};
};
Also bear in mind that the calls are Asynchronous, so you cant execute a request and assert the response within each test.
I therefore have a chain of setup methods (to call the Ajax.request) and callbacks (1 of each for each test) - these are kicked off on pageSetup and my callbacks stores the relevant data to test.
After my setup chain has completed I use:
PHP Code:
function setupComplete() {
setUpPageStatus = 'complete';
}
... and then my tests run and assert the stored values from each callback.
Apart from some more tricky UI stuff I haven't found any part of Ext that I couldn't test with JSUnit and MockJS.
Hope this helps,