Get help with testing, discuss unit testing strategies etc.


Post by nickolay »

Not yet, will check soon.

Post by nickolay »

So I just checked, and it seems things has changed significantly in the recent Ext versions. The application loading now happens inside the "bootstrap.js" and does not use Ext.require(). Thus, Siesta presently does not support gathering code coverage information for the tests with "pageUrl" config.

You still can generate this report for tests that uses regular "preload" + on-demand loading. Here's a sample app (default app generated by sencha cmd): https://yadi.sk/d/8LSI13ag3RYDLo

Refer to the "tests" folder. Need to place Ext6.5.2 into the "MyApp/ext" and siesta into "MyApp/tests/siesta".

We plan to rewrite the code coverage feature and make it more generic, after that it will be possible to use it for all types of tests. Realistically thats not earlier than Q2 .

Post by nuridesengin »

I'll examine your sample and inform on here.
Thanks a lot for your effort dear nickolay.

Post by nuridesengin »

Dear nickolay here is the result of my application through your sample. Unfortunately I couldn't be fully success yet :|
  • * Test threw exceptions: ReferenceError: translations is not defined
    * Includes only one test file but I'm state two unit-test file: Globals.js and it's test file + SessionMonitor.js and it's test file
    * Coverage folder produces under computer's User root folder: /Users/myuser/coverage. It should produce under application folder where test folder located.
Screenshot @ https://prnt.sc/i24q48
Whole Coverage Folder @
coverage.zip
CoverageZip
(2.14 MiB) Downloaded 212 times
I've set test environment as this way;
harness.configure({
    title               : 'MyApp Test Runner',
    viewDOM             : true,
    enableCodeCoverage  : true,
    coverageUnit        : 'file',
    waitForTimeout      : 20000,
    runCore             : 'sequential'
});

harness.start(
    {
        group   : 'Unit Tests',
        preload         : [
            '../../../ext/build/ext-all-debug.js' // Chrome Network: Status 200
        ],

        loaderPath      : {
            'MyApp'     : '../../app'
        },

        installLoaderInstrumentationHook    : true,

        requires        : [
            'MyApp.Globals', // Chrome Network: Status 200
            'MyApp.utils.SessionMonitor' // Chrome Network: Status 200
        ],

        items   : [
            '01-unit-tests/010_globals.t.js', // Test Threw exception: ReferenceError: translations is not defined
            '01-unit-tests/020_sessionmonitor.t.js' // Test Threw exception: ReferenceError: translations is not defined
        ]
    },
globals.t.js // Here are some test assertions; before harness configuration some of them PASSED some are FAILED.
describe('MyApp Globals unit-test', function(t) {
    t.ok(MyApp.Globals, 'Found Globals.js');

    t.describe('getStatusDesc() method', function(t) {
        t.it('should return \'A\' as status description', function(t) {
            t.expect(MyApp.Globals.getStatusDesc('A')).toEqual('Future');
        });
    });

    t.describe('getGlyph() method', function(t) {
        t.it('should return \'add\' ass webfont-code', function(t) {
            t.expect(MyApp.Globals.getGlyph('add')).toEqual('xf067@FontAwesome');
        });
    });
SessionMon.t.js // Here are some test assertions; before harness configuration as well on here some of them PASSED some are FAILED.
describe('MyApp utils/SessionMonitor unit-test', function(t) {

    t.ok(MyApp.utils.SessionMonitor, 'Found SessionMonitor.js');

    t.describe('captureActivity() method', function(t) {
        t.it('should return a new Date object', function(t) {
            t.expect(MyApp.utils.SessionMonitor.captureActivity(new Date())).toEqual(new Date());
        });
    });

    t.describe('monitorUI() method', function(t) {
        t.it('should return an undefined', function(t) {
            t.expect(MyApp.utils.SessionMonitor.monitorUI()).toEqual('undefined');
        });
    });
Here is translations.js which probably effects Test Environment!?
//Root: myapp/resources/locales/en.js
translations = {
    active: 'Active',
    add: 'Add',
and we are using those translations on both of unit-test file as this way, Globals.js
Ext.define('MyApp.Globals', {
     .....
     status: {
             'A': translations.future,
             'E': translations.expected,
Finally here is terminal command I am using;
other-sdks/Siesta/siesta-4.4.0-standard/bin/webdriver https://localhost:1841/myapp/test/Siesta/index.html --browser-arg disable-web-security --coverage-report-format=html
  • * As well I would like to point that; coverage folder is keep producing under ROOT directory of computer. (/Users/myuser/coverage). How can I set it directory navigation to produce this folder under application folders?

Post by nickolay »

Well, test clearly says, that "translations" is not defined. This means its not loaded, which is expected, since its not included in the "preload" config.

To specify the location of coverage report use --coverage-report-dir option

Post by nuridesengin »

And... finally all sets!! :)

Dear nickolay. Thank you very much for all your effort, support. I got the report exactly how I expected. I know I'll hang around a long time but hopefully will come over here for much more easier staff. =)

Post by nickolay »

Cool-cool, yw :)

Post Reply