Results 1 to 2 of 2

Thread: Reference Error for Sencha Test

  1. #1
    Sencha User
    Join Date
    Jun 2017

    Default Reference Error for Sencha Test

    I'm trying a simple unit test with Sencha Test but keep taking this error;

    System error: ReferenceError: myDemoApp is not defined at Object.<anonymous> (/Users/frontend/la-nuri/Dev/Demo/MyDemoApp/test/DemoScenario/DemoSuite2.js:6:27) at (/Applications/Sencha/Test/2_1_2_1/Sencha at Object.invoke (/Applications/Sencha/Test/2_1_2_1/Sencha at (/Applications/Sencha/Test/2_1_2_1/Sencha at attemptAsync (/Applications/Sencha/Test/2_1_2_1/Sencha at (/Applications/Sencha/Test/2_1_2_1/Sencha at QueueRunner.execute (/Applications/Sencha/Test/2_1_2_1/Sencha at Spec.queueRunnerFactory (/Applications/Sencha/Test/2_1_2_1/Sencha at Spec.execute (/Applications/Sencha/Test/2_1_2_1/Sencha at Object.fn (/Applications/Sencha/Test/2_1_2_1/Sencha
    I've generate a sample app with `sencha cmd` through this guide with this command;

    sencha generate app -ext MyApp /path/to/my-app
    Here is my test suite and some other code snippets. My reference for test suite is Arthur Kay's github repo which explain unit-tests for ExtJS apps;

     describe('Demo Suite 2', function() {
            describe('onConfirm() method', function() {
                it('should be a function', function() {
                    expect(typeof myDemoApp.view.main.MainController.onConfirm).toEqual('function');
                it('should return a string', function() {
                    expect(typeof myDemoApp.view.main.MainController.onConfirm()).toEqual('string');

    This is sencha-made controller;

         * This class is the controller for the main view for the application. It is specified as
         * the "controller" of the Main view class.
        Ext.define('myDemoApp.view.main.MainController', {
            extend: '',
            alias: 'controller.main',
            onItemSelected: function (sender, record) {
                Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
            onConfirm: function (choice) {
                if (choice === 'yes') {
                    console.log("this is a yess")
    I want to check `onConfirm` method with that simple unit test suite. Why cannot reach to `myDemoApp`?

  2. #2
    Sencha - Sales Team's Avatar
    Join Date
    Apr 2009
    London, England


    Based on the error, it looks like you may be trying to run these tests from a WebDriver scenario, so "myDemoApp" would be undefined in that context as the tests will be running separate from the browser.

    For unit tests, and in order to reference "myDemoApp", your tests need to run in-browser alongside your app code. If you edit the details of the Scenario and select "In-Browser" as the type, as opposed to "WebDriver", the tests should pass.
    Daniel Gallo

Similar Threads

  1. Replies: 1
    Last Post: 13 Jun 2017, 8:53 AM
  2. Sencha Test CLI node error
    By Artem_Ivanov in forum Q&A
    Replies: 2
    Last Post: 6 Feb 2017, 11:34 PM
  3. Replies: 1
    Last Post: 3 Feb 2017, 8:59 AM
  4. Replies: 1
    Last Post: 9 Aug 2016, 3:46 AM
  5. Replies: 2
    Last Post: 4 Aug 2016, 4:27 AM

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