I would like to setup a proper testing environment for a Sencha Touch 2 app using jasmine.
I used the first three parts of this tutorial for my first steps:
- https://content.pivotal.io/blog/sencha-touch-bdd-part-1
- https://content.pivotal.io/blog/sencha-touch-bdd-part-2
- https://content.pivotal.io/blog/sencha-touch-bdd-part-3-testing-views-and-mocking-stores
My actual problem is the following: two config entries for two of my classes (one store and one view) need to call methods / read properties of my main app object respectively the Ext.Viewport object.
Concrete:
1.) one of my stores reads a value on the main namespace of my app (MyAppName.app.backendUrl)
Ext.define('MyAppName.store.MyStore', {
extend: 'Ext.data.Store',
config: {
model: 'MyAppName.model.MyModel',
proxy: {
type: 'ajax',
url: MyAppName.app.backendUrl + '/data.json',
reader: 'json'
},
autoLoad: true
}
});
2.) one of my views does call a method (Ext.Viewport.getOrientation()) on Ext.Viewport:
Ext.define('MyAppName.view.LoginView', {
extend: 'Ext.form.Panel',
alias: "widget.loginview",
config: {
title: 'Login',
items: [
{
xtype: 'image',
src: Ext.Viewport.getOrientation() == 'portrait' ? '../../../img/login.png' : '../../../img/login-small.png',
style: Ext.Viewport.getOrientation() == 'portrait' ? 'width:80px;height:80px;margin:auto' : 'width:40px;height:40px;margin:auto'
}
]
}
});
Unfortunately, this crashes, because both objects (MyAppName and Ext.Viewport) are not yet defined when these calls are made. This is only the case for the testing setup (as the tutorial outlines, there is a specific app.js just for the testing). When I run the actual app in the browser (via the 'normal' app.js), this problem does not occur.
How could this be fixed (so: how can I make sure that my views/store files are run AFTER MyAppname.app and Ext.Viewport already exist)?
Thanks a lot.
You need to spec/javascripts/support/jasmime.yml the files you need in the right order :