How to access Ext JS project objects in Test?

Get help with testing, discuss unit testing strategies etc.
Post Reply
User avatar
berkancimen
Posts: 6
Joined: Fri Oct 26, 2018 4:24 pm

How to access Ext JS project objects in Test?

Post by berkancimen » Fri Oct 26, 2018 4:55 pm

Hi,

I have a 'myStrings' object in Ext Js app folder. In project files I can easily get variables in that object like 'myStrings.stringOne'.

Code: Select all

myStrings = {
stringOne: 'One',
stringTwo: 'Two',
.......
}
Usage:

Code: Select all

Ext.define('myApp.view.classA', {
title: myStrings.stringOne,
}
Here is my test case and the place where I have trouble with:

Code: Select all

describe('UI Test', function (t) {
t.chain({navFunction: [ myStrings.stringOne ]}) ;
});
I have to use myStrings.stringOne as parameter. But I get " ReferenceError: myStrings is not defined ". Any help would be appreciated.

User avatar
mats
Core Developer
Core Developer
Posts: 14589
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: How to access Ext JS project objects in Test?

Post by mats » Sun Oct 28, 2018 6:41 pm

Are you preloading it in your test? Can you perhaps upload a small test case we can inspect / run?
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
berkancimen
Posts: 6
Joined: Fri Oct 26, 2018 4:24 pm

Re: How to access Ext JS project objects in Test?

Post by berkancimen » Tue Oct 30, 2018 8:44 am

Here is index.js file:

Code: Select all

let project = new Siesta.Project.Browser.ExtJS();

project.configure({
    title: 'Test Runner',
    viewDOM: true,
    enableCodeCoverage: true,
    autoScrollElementsIntoView: true,
    viewportHeight  : 1100,
    viewportWidth   : 900,
    coverageUnit: 'file',
    runCore: 'sequential',
    separateContext: true,
    preload: [
        '....../resources/myStrings.js'
    ]
});

project.plan(
    {
        group: 'Application Tests',
        testClass: Siesta.Test.TestClass,
        items: [
         // Test cases here...
        ]
    }
};

project.start();
And test case class:

Code: Select all

Class('Siesta.Test.TestClass', {
    isa     : Siesta.Test.ExtJS,

    methods: {
     nav: function (subMenu,  callback) {
      let t = this;

      t.it('Test', function (t) {
         t.chain(
...............
             {click: '#main-home .x-treelist-item-expanded .x-treelist-item-text:textEquals('+ subMenu +')', desc: 'Choose Sub-Menu item' },
..............
              callback
             );
         });
     }, 
  }
}
And lastly my test suite:

Code: Select all

describe('UI Test Case', function (t) {
    t.chain({nav: [myStrings.stringOne]});
});

User avatar
mats
Core Developer
Core Developer
Posts: 14589
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: How to access Ext JS project objects in Test?

Post by mats » Tue Oct 30, 2018 10:37 am

Could you please zip this up so we can try run it? The most basic test which fails for you is enough
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
berkancimen
Posts: 6
Joined: Fri Oct 26, 2018 4:24 pm

Re: How to access Ext JS project objects in Test?

Post by berkancimen » Tue Oct 30, 2018 2:11 pm

Sorry for late replies. You can download zip file from attachment.

projectOne.zip
I had to remove test/siesta/resources folder because of it's size.
(17.94 KiB) Downloaded 31 times

User avatar
nickolay
Core Developer
Core Developer
Posts: 3355
Joined: Mon May 16, 2011 10:48 am

Re: How to access Ext JS project objects in Test?

Post by nickolay » Wed Oct 31, 2018 9:58 am

Perhaps you use a "pageUrl" option. In this case the "preload" option behaves a bit differently, see the docs: https://www.bryntum.com/docs/siesta/#!/ ... fg-preload

You need to specify the `preload : "inherit"`basically
We offer training in both Ext JS and our products, read more here.
Read the API documentation

Post Reply