Setting up Jasmine with ExtJS for Unit Testing - Conclusion


That's all there is to getting Jasmine working with your ExtJS application. The bigger issue is figuring out tests that truly add value to your application.

I'm including the spec file below that I created for my JasmineExample project. This was the culmination of only 2 hours of Jasmine experience. As I work more with Jasmine, I'll share ideas on what seems to be beneficial.

// File initial.js
describe ("Initial", function(){ var app = null, controller = null, store = null, viewPort = null; beforeEach(function () { // Test to see if the app loaded if (!app){ app = JasmineExample.getApplication(); expect(app !== null).toBeTruthy(); } // Test the existence of the Main controller if (!controller){ controller = app.getController('Main'); expect( == "Main").toBeTruthy(); } // Get the initial view. For convenience query from it. if (!viewPort) { viewPort = Ext.ComponentQuery.query('viewport')[0]; expect(viewPort.xtype === 'viewport').toBeTruthy(); } // Verify the Cars store is attached to the Main controller. if (!store) { store = controller.getCarsStore(); expect(store.storeId == "Cars").toBeTruthy(); // Wait for it to load waitsFor( function() {return !store.isLoading(); }, "load never completed", 4000 ); } }); // before each it("Cars grid is found with the proper store and loaded", function(){ var grid = viewPort.query('grid')[0]; // Test that the grid panel was found expect(grid !== null).toBe(true); // Test that the store attached to the grid is the Cars store expect(grid.getStore().storeId == "Cars").toBeTruthy(); // Test the the number of initial records is 2 expect(grid.getStore().getCount() == 2).toBe(true); }); }); // describe Selector