Testing Ext JS applications

Testing is a very important part when developing applications or providing maintenance. When we do not write tests, we need to verify each use case manually, and if we change anything on the code, we will need to perform all the testing manually again. The same happens when we need to maintain the code; developers usually test only what has been changed, but the correct thing to do would be regression tests to see whether the change did not break anything else. So spending some time writing tests can be a win at the end. You will spend a little bit more time writing code, but then you will be able to run all the tests with a single click and then verify what is broken and what is still working.

We are also very used to performing unit tests on the server-side code. Java, PHP, Ruby, C# communities offer a lot of options to perform unit tests on the server-side code, and sometimes, we can forget to test the frontend code (in this case Ext JS). But do not worry; there are a few tools we can use to include Ext JS on the tests as well.

One tool that is very popular for JavaScript testing in general is Jasmine (http://jasmine.github.io/). Jasmine is a testing tool that is used for Behavior-Driven Development (BDD)—(http://en.wikipedia.org/wiki/Behavior-driven_development). In Ext JS documentation, you can find two guides explaining how to test Ext JS applications with Jasmine: http://docs.sencha.com/extjs/4.2.0/#!/guide/testing and http://docs.sencha.com/extjs/4.2.0/#!/guide/testing_controllers. Although the guides were written for Ext JS 4.x, they can also be applied to Ext JS 5.

There is also a testing framework designed specially for a Sencha application called Siesta (http://www.bryntum.com/products/siesta/). Siesta can also be used to test JavaScript code in general, but the cool side of Siesta is that it provides a special API so that we can test Ext JS applications, including tests on user interface components. Siesta comes with some great examples that can be used to start writing our own test cases.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset