Get help with testing, discuss unit testing strategies etc.


Post by sdruckerfig »

I've got the following test:
StartTest(function(t) {

    t.describe("Create New Service", function(t) {

        t.chain({
                click: "button[text=Create a New Service] => .x-btn-inner-default-toolbar-small"
            },

            {
                type: "T",
                target: "#messagebox-1001-textfield => .x-form-text",
                options: {
                    shiftKey: true
                }
            },

            {
                type: "est ",
                target: "#messagebox-1001-textfield => .x-form-text"
            },

            {
                type: "S",
                target: "#messagebox-1001-textfield => .x-form-text",
                options: {
                    shiftKey: true
                }
            },

            {
                type: "ervice",
                target: "#messagebox-1001-textfield => .x-form-text"
            },

            {
                click: "#ok => .x-btn-inner-default-small"
            },

            {
                click: "servicedetails[title=Service Details] textfield[fieldLabel=Title] => .x-form-text"
            },


            function() {
                var wizard = Ext.ComponentQuery.query('wizard')[0];
                t.ok(wizard, 'Wizard instantiated');
                var vm = wizard.getViewModel();
                t.ok(vm, 'Wizard viewmodel instantiated');
                var dataEntity = vm.get('dataEntity');
                t.ok(dataEntity, 'DataEntity model instance available');

                // used in cleanup
                t.midasCleanup = {
                    settings: MyApp.settings,
                    dataEntityId: dataEntity.get('id')
                };

                t.ok(dataEntity.phantom === false, "DataEntity was saved to web service -- " + t.midasCleanup.dataEntityId);

            }
        );


    });

});
The test runs fine until I link in a teardown override:
Class('My.Test.Class', {

    isa: Siesta.Test.Browser,

    override: {

        tearDown: function(callback, errback) {
            debugger;
            if (!this.midasCleanup) {
                callback();
                return;
            } else {
                debugger;
                if (this.midasCleanup.dataEntityId) {
                    Ext.Ajax.request({
                        url: '',
                        success: function() {
                            callback();
                        },
                        failure: function() {
                            errback("Failed to delete DataEntity " + this.midasCleanup.dataEntityId);
                        }
                    });
                }
            }

        }
    }
});
With the teardown in place, a syntax error is always thrown on the first line of the script:
Subtest `Create New Service` threw an exception
Error: Syntax error, unrecognized expression: button[text=Create a New Service] => .x-btn-inner-default-toolbar-small
    at line 28462, character 8, of https://localhost/siesta/siesta-all.js
    at line 29114, character 11, of https://localhost/siesta/siesta-all.js
    at line 29541, character 20, of https://localhost/siesta/siesta-all.js
    at line 27760, character 9, of https://localhost/siesta/siesta-all.js
    at line 23581, character 24, of https://localhost/siesta/siesta-all.js
    at line 18578, character 56, of https://localhost/siesta/siesta-all.js
    at line 27392, character 20, of https://localhost/siesta/siesta-all.js
    at line 39970, character 27, of https://localhost/siesta/siesta-all.js
    at line 825, character 32, of https://localhost/siesta/siesta-all.js
    at line 40187, character 36, of https://localhost/siesta/siesta-all.js
I'm new to Siesta, but this seems like a bug?

Post by nickolay »

Seems you are testing ExtJS application - then inherit from Siesta.Test.ExtJS:
Class('My.Test.Class', {

    isa: Siesta.Test.ExtJS,

    override: {
Please let me know if that fixed the problem.

Post by sdruckerfig »

Indeed it did. Thanks!!!

Post Reply