Results 1 to 1 of 1

Thread: [APPNAME].app is undefined only when testing with Jasmine

  1. #1
    Sencha User
    Join Date
    Sep 2015
    Posts
    8

    Default [APPNAME].app is undefined only when testing with Jasmine

    I'm trying to set up some test cases for a view using the Jasmine 2.3.4 assertion library for my Touch 2.4 app. Things seem great (I see the view rendered to a div) except the browser does not know what MyApp.app is. I have this line at my onContainerInitialize function from my view/container code:
    Code:
    var controller = MyApp.app.getController('loginController');
    which gives this Jasmine result:
    TypeError: Cannot read property 'getController' of undefined

    At the time the Jasmine tests are called, from my console I do have a MyApp global object with the following structure (attached). If you expand app you will see the class name of the controller listed in an array under _controllers. The line that causes this error in my spec file is:
    Code:
    var myView = new MyApp.view.someViewName({ renderTo: 'test' });
    I modeled my setup after a few tutorials, one of which is Sencha's https://docs.sencha.com/extjs/4.2.5/#!/guide/testing
    (wish there was one for a recent version of Touch). I think my problem may be related to this note midway down that page:

    Note: this Application definition is not a copy and paste of your regular Application definition in your app.js. This version will only include the controllers, stores, models, etc and when launch is called it will invoke the Jasmine tests.
    It may be related, but I also couldn't follow their:

    ctrl =newMyApp.controller.MyController();where I would get this error:
    TypeError: app.getRouter is not a function at Ext.define.applyRoutes (http://localhost:8080/touch/sencha-t...ug.js:45800:26)
    Instead, I had to add in this argument like this:
    Code:
    var ctrl = new Kaacoo.controller.loginController({
                    application : app
                });
    Additionally, my launch file is set up like this:
    Code:
    Ext.require('Ext.app.Application');
    
    
    Ext.Loader.setConfig({
        enabled: true,
        disableCaching: true
    });
    
    
    Ext.Loader.setPath('MyApp', '../../app');
    // this file is a couple levels deep from the root of my project
    
    
    Ext.application({
        name : 'MyApp',
        extend: 'MyApp.Application',
        autoCreateViewport: true,
    
    
        controllers: [
            'loginController'
        ],
    
    
        requires : [
        ],
    
    
        launch: function() {
            // Jasmine is bootstrapped with boot.js referenced in the html runner, so nothing here.
        }
    });
    The order I have listed my resources in my html runner are: Jasmine Library with boot.js> Touch All Debug Library > Source Files with app.js > Spec Files > Launch file

    Building and simulating the app is fine, so why can't I also have access to MyApp.app.getController('loginController') as well in my test environment?

    Thanks!
    Attached Images Attached Images

Similar Threads

  1. Ext JS 4.x view Testing - Jasmine
    By vipinsudhakar in forum Ext: Q&A
    Replies: 1
    Last Post: 20 Feb 2014, 8:06 AM
  2. [FIXED] Bug in Jasmine testing doco (with fix)
    By davecrane in forum Ext:Bugs
    Replies: 1
    Last Post: 10 May 2013, 8:36 AM
  3. Jasmine testing, how to set it up correctly
    By zwikske in forum Sencha Touch 2.x: Discussion
    Replies: 1
    Last Post: 7 Jan 2013, 12:30 AM
  4. Unit testing with Jasmine
    By ccornutt in forum Ext: Discussion
    Replies: 4
    Last Post: 8 Dec 2011, 3:45 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •