PDA

View Full Version : Testing Extjs controller with Jasmine returns TypeError



anar
10 Jan 2014, 5:16 AM
We have set up a unit testing environment. PhantomJS will provide a headless browser to simulate the tests and the tests will be written in Jasmine framework. For simple examples (testing simple JS code) everything works fine. We have problems figuring out how should the Jasmine code for running a test for a Sencha ExtJS 4.2 controller look like. For example we have set up a simple Sencha project that inserts an item into the store on a button click.


47537

Below is the test code in Jasmine that should test if a button was clicked.

47536


But the code gives an error in the second test:


TypeError: 'undefined' is not an object (evaluating 'generateButton.fireEvent') in file:///home/anar/SenchaArchitect3/TestProject/UnitTests/TestControllerSpec.js (line 76)

What exactly are we doing wrong and is our approach the right one?

scottmartin
10 Jan 2014, 5:41 AM
Here are a few links regarding unit testing with Jasmine:

http://www.sencha.com/blog/ui-testing-a-sencha-app
http://www.sencha.com/blog/automating-unit-tests
http://www.sencha.com/blog/headless-testing-for-continuous-integration-with-git-and-jasmine/
http://www.akawebdesign.com/2013/02/01/building-unit-tests-for-sencha-apps/

mirkotus
10 Jan 2014, 5:49 AM
Do we have to create all the components we want to test again in the test cases or can we just simulate events on the components created in the Sencha project? I hope you understand what I mean.

scottmartin
10 Jan 2014, 6:03 AM
To be honest, I am not sure. Hopefully someone with first hand knowledge can provide you with more info.

Regards,
Scott.