Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sample Extjs5 App for Unit testing with Jasmine and Karma-runner

I'am new to Extjs5 and trying to run jasmine unit test cases with karma-runner. Although am sucessfully able to do that fro Ext4.2 application but same process is not working for Extjs5.

I have goggled it but didn't got any useful link

If anyone have already executed for Ext5 app please share the code.

Any help is highly appreciated.

Thanks Tapaswini

like image 802
user2211050 Avatar asked Dec 05 '25 19:12

user2211050


1 Answers

The trick is to allow the required ExtJS classes to properly load before you start your test. Make sure you include the following in your karma.conf.js

// We need to add an element with the ID 'appLoadingIndicator' because [app.js].launch() is     expecting it and tries to remove it

// Karma normally starts the tests right after all files specified in 'karma.config.js' have been loaded
// We only want the tests to start after Sencha Touch/ExtJS has bootstrapped the application
// 1. We temporary override the '__karma__.loaded' function
// 2. When Ext is ready we call the '__karma__.loaded' function manually
var karmaLoadedFunction = window.__karma__.loaded;
window.__karma__.loaded = function () {
};

bootstrapExtJS(); // Create this function to add anything that is not included in your class definition requires and you need to require explicitly

Ext.onReady(function () {
  window.__karma__.loaded = karmaLoadedFunction;
  window.__karma__.loaded();
});

Let me know if it works for you.

like image 92
Gabriel Kohen Avatar answered Dec 08 '25 11:12

Gabriel Kohen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!