jbrown
jbrown

Reputation: 61

How do I properly setup app-test.js when unit testing ExtJS using Jasmine?

I am fairly new to both Jasmine(2.2) as well as ExtJS(4.2.1). I am following the Unit Testing instructions in the Sencha docs to test the feed-viewer example ExtJS application. I cannot seem to get the app-test file quite right to load the application.

Here is my app-test.js

Ext.Loader.setConfig({ enabled : true });
var Application = null;
Ext.onReady( function() {
    Application = Ext.create('app', {
        name: 'FV',
        controllers: [
           'Articles'
        ],
        launch: function() {
            var jasmineEnv = jasmine.getEnv();
            jasmineEnv.updateInterval = 1000;
            jasmineEnv.execute();
        }
    });
});

Here is the app.js

Ext.application({
    name: 'FV',
    paths: {
        'Ext.ux': '../../../examples/ux/'
    },
    controllers: [
        'Articles',
        'Feeds'
    ],
    autocreateViewport: true
});

And, in case this may be a part of the issue, my folders are structured as such:

FV/
  - app/
  - app-test/
    - resources/
    - specs/
  - app.js
  - app-test.js
  - run-test.html

My test to see that the application has been properly loaded is failing. Chrome's dev tools show me two errors. The first is an XMLHttpRequest cannot load, and the second is an Uncaught TypeError: Object is not a function being thrown at the third line of app-test.js

I feel like there's something remarkably simple I may have missed.

Any help would be immensely appreciated!

Upvotes: 2

Views: 1192

Answers (1)

jbrown
jbrown

Reputation: 61

I finally got it working. Here is my revised app-test.js

Ext.Loader.setConfig({ enabled : true });
Ext.ns('FV');
Ext.application({
    name: 'FV',
    appFolder: 'app',
    controllers: ['Articles'],
    autoCreateViewport: false,
    launch: function() {
        var jasmineEnv = jasmine.getEnv();
        jasmineEnv.updateInterval = 1000;
        jasmineEnv.execute();
    }
});

Considering how different this is from the tutorial in the Sencha docs, and how much Jasmine has changed since 1.1.0 (which is the version their tutorial uses), it's definitely time for them to do an update.

Upvotes: 3

Related Questions