DanilaMactep
23 Apr 2014, 12:57 PM
I'm trying to setup unit testing for my ext js application.
I'm using Jasmine and PhantomJS to run the tests from console.
I can successfully init the store in the init method of the controller.
But, if I try to declare it in the stores config, I'm getting the following error :
TypeError: 'null' is not a constructor (evaluating 'new c()') (line 1) (1) ,
What is the cause for the error, and how can it be resolved?
Thank you in advance.
My code is below:
TestApplication.js
Ext.Loader.setConfig({ enabled: true });
Ext.ns('myApp');
// Loading different components like controller, model, view..
Ext.application({
name: 'myApp',
appFolder: '../App',
controllers: [],
autoCreateViewport: false,
init : function() {
myApp.app = this;
},
// Launch Jasmine test environment
launch: function () {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.execute();
}
});
spec.js
describe("myController", function () {
var ctrl= null,
store = null;
beforeEach(function () {
bmTab = Ext.create("myApp.controller.myController");
bmTab.init();
});
});
myController.js
Ext.define('myApp.controller.myController', {
extend: 'Ext.app.Controller',
//stores: [Stores.myStore],
init:function() {
console.log('**** init');
var store = Ext.create(Stores.myStore);
console.log('**** store created' + store);
}
});
I'm using Jasmine and PhantomJS to run the tests from console.
I can successfully init the store in the init method of the controller.
But, if I try to declare it in the stores config, I'm getting the following error :
TypeError: 'null' is not a constructor (evaluating 'new c()') (line 1) (1) ,
What is the cause for the error, and how can it be resolved?
Thank you in advance.
My code is below:
TestApplication.js
Ext.Loader.setConfig({ enabled: true });
Ext.ns('myApp');
// Loading different components like controller, model, view..
Ext.application({
name: 'myApp',
appFolder: '../App',
controllers: [],
autoCreateViewport: false,
init : function() {
myApp.app = this;
},
// Launch Jasmine test environment
launch: function () {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.execute();
}
});
spec.js
describe("myController", function () {
var ctrl= null,
store = null;
beforeEach(function () {
bmTab = Ext.create("myApp.controller.myController");
bmTab.init();
});
});
myController.js
Ext.define('myApp.controller.myController', {
extend: 'Ext.app.Controller',
//stores: [Stores.myStore],
init:function() {
console.log('**** init');
var store = Ext.create(Stores.myStore);
console.log('**** store created' + store);
}
});