Get help with testing, discuss unit testing strategies etc.


Post by sqatester123 »

I'm getting a reference error when I try to run a component query within my test case. I tried adding extjs-all-debug.js to my harness and that didn't help. I also tried including it in my index.html file but I get a different error when doing that. The error is "Error: [Ext.createByAlias] Unrecognized alias: controller.viewport".

Any idea what might be causing this issue?

Post by mats »

Can you please provide a test case? Guessing what's wrong is really really hard :)

Post by Maxim Gorkovsky »

Hello.
It can be caused by inline controller definition in Ext 6.0.2 or by missing requirement in your app.

Post by sqatester123 »

Sure thing.

Here's my index.html code.
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

        <title>Siesta Harness</title>
        
        <link rel="stylesheet" type="text/css" href="siesta/resources/css/siesta-all.css">
        <script type="text/javascript" src="siesta/siesta-all.js"></script>
        <script type="text/javascript" src="ext-6.2.0/build/ext-all-debug.js"></script>
        <script type="text/javascript" src="harness.js"></script>
    </head>

    <body>
    </body>
</html>
Here's my harness.
var harness = new Siesta.Harness.Browser.ExtJS();

harness.configure({
    title: 'Siesta Harness',
    preload: ['ext-6.2.0/build/ext-all-debug.js']
});

harness.start(
    {
        group: 'Tests',
        expanded: true,
        separateContext: true,
        items: [
            {
                // url: 'harness_case.js',
                url: 'sandbox_case.js',
                name: 'Siesta Harness',
                pageUrl: 'https://127.0.0.1:8443/OneView/home?notop=true',
                name: 'Siesta Harness',
                separateContext: true
            }
        ]
    }
);
And my test case (it doesn't do much).
StartTest(function(t) {
    var result = Ext.ComponentQuery.query("treeview[id=treeview-1125]")[0].id;
    t.diag(result);
    }
)

Post by mats »

When using pageRedirect, 'window' points to the 'top' window (where the Siesta application lives). You want to do:
t.global.Ext.ComponentQuery.query("treeview[id=treeview-1125]")[0].id;
or use https://bryntum.com/docs/siesta/#!/api/ ... method-Ext
t.Ext()

Post by sqatester123 »

I tried both ways and each produced an error.

Using t.global.Ext.ComponentQuery.query("treeview[id=treeview-1125]")[0].id; I got
TypeError: t.global.Ext is undefined

Using t.ext() I got
TypeError: t.Ext(...) is undefined

Post by nickolay »

Also do not include ext-all-debug.js in your harness html file. Your tests are running in isolated iframes, which are not related to the harness html.

Post by mats »

Hm, is Ext maybe loaded on demand somehow on your page?

Then maybe this could work before you start your test:
t.chain( 
{ waitFor : function() { return t.global.Ext; }}
)

Post by sqatester123 »

Removed extjs preload from the harness and added the following to the test case.
t.chain(
{ waitFor : function() { return t.global.Ext; }}
)
But I still get a type error when calling
var result = t.global.Ext.ComponentQuery.query("treeview[id=treeview-1125]")[0].id;

Post by nickolay »

Try waiting for the ComponentQuery may be:
{ waitFor : function() { return t.global.Ext && t.global.Ext.ComponentQuery; }}


May be this flag will help also: https://local/workspace/JavaScript/siest ... orAppReady

Post Reply