Get help with testing, discuss unit testing strategies etc.


Post by nuridesengin »

Hello again.

I am trying to use some global variables within Test suite. Therefore tried to define several variables in TestClass and calling them in test file. During running the web-runner getting this error:
Subtest `Update the form data` threw an exception
ReferenceError: DBLBACKSPACE is not defined
Somehow I can find the variable's usage with IDE but test suite can not. Is there any way to make this purpose? Here is some snippets from Test Suite;

Test Class:
var BACKSPACE = '[BACKSPACE][BACKSPACE]';
var DBLBACKSPACE = '[BACKSPACE][BACKSPACE][BACKSPACE][BACKSPACE]';

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

    methods: {
    ...
and the test file I'm trying to call variable:
describe('UI Testing: Submodule Data Screen', function (t) {
 t.it('Update the form data', function (t) {
        var next = t.next;

        t.chain(
            {clickAndType: ['firstnamefld[name=firstname]', DBLBACKSPACE + 'Updated First Name']},
            {clickAndType: ['lastnamefld[name=lastname]', DBLBACKSPACE + 'Updated Last Name']},
            ...
As you will notice I keep using 'type: [BACKSPACE]' several times during updating form data. Thusly aim to make it easier :)

Post by mats »

Don't use global variables, put these as Test class variables instead:
Class('Siesta.Test.DataScreen', {
   isa: Siesta.Test.ExtJS,

    has: {
             BACKSPACE : '[BACKSPACE][BACKSPACE]',
             DBLBACKSPACE : '[BACKSPACE][BACKSPACE][BACKSPACE][BACKSPACE]'
    },
    ...
})
In your test, just access this on the test instance (t)
            {clickAndType: ['firstnamefld[name=firstname]', t.DBLBACKSPACE + 'Updated First Name']},



Joose docs: https://joose.github.io/Joose/doc/html/Joose.html

Post by nuridesengin »

I just get the usage of has attribute. Thanks a lot dear Mats...
Hopefully next time Joose docs will be good enough instead of posting here.

and of course it works :)

Post Reply