Intern.io Single Page Application Functional Testing -
i have single page application uses dojo navigate between pages. writing functional tests using intern , there niggly issues trying weed out. having trouble getting intern behave timeouts. none of timeouts seem have effect me. trying set initial load timeout using "setpageloadtimeout(30000)" seems ignored. call "setimplicitwaittimeout(10000)" again seems have no effect.
the main problem have may take couple of seconds in test environment request sent , response parsed , injected dom. way have been able around explicitly calling "sleep(3000)" example can bit hit & miss , dom elements not ready time query them. (as mentioned setimplicitwaittimeout(10000) doesn't seem have effect me)
with application fire event when dom has been updated. use dojo.subscribe hook in applictaion. possible use dojo.subscribe within intern control execution of tests?
heres sample of code. should have mentioned use dijit there slight delay when response comes , widgets being created (via data-dojo-type declarations)...
define([ 'intern!object', 'intern/chai!assert', 'require', 'intern/node_modules/dojo/topic' ], function (registersuite, assert, require, topic) { registersuite({ name: 'flow1', // login application 'login': function(remote) { return remote .setpageloadtimeout(30000) .setimplicitwaittimeout(10000) .get(require.tourl('https://localhost:8080/')) .elementbyid('username').clickelement().type('user').end() .elementbyid('password').clickelement().type('password').end() .elementbycssselector('submit_button').clickelement().end(); }, // check first page 'page1':function() { return this.remote .setpageloadtimeout(300000) // i've tried these calls in various places... .setimplicitwaittimeout(10000) // i've tried these calls in various places... .title() .then(function (text) { assert.strictequal(text, 'page title');}) .end() .active().type('test').end() .elementbycssselector("[title='click here help']").clickelement().end() .elementbyid('next_button').clickelement().end() .elementbycssselector("[title='first name']").clear().type('test').end() .elementbycssselector("[title='gender']").clear().type('female').end() .elementbycssselector("[title='date of birth']").type('1/1/1980').end() .elementbyid('next_button').clickelement().end(); }, // check second page 'page2':function() { return this.remote .setimplicitwaittimeout(10000) .sleep(2000) // need sleep here wait request & response injection , dom parsing etc... .source().then(function(source){ assert.istrue(source.indexof('test') > -1, 'should contain first name: "test"'); }).end() // more tests etc... } }); });
i'm importing relevant dojo module intern dojo node module i'm unsure of how use it.
thanks
your test timing out, because intern tests have explicit timeout set 30s not accessible through api. can changed adding 'intern/lib/test'
define array, , overwriting timeout test's object, e.g. test.prototype.timeout = 60000;
.
for example:
define([ 'intern!object', 'intern/chai!assert', 'require', 'intern/node_modules/dojo/topic', 'intern/lib/test' ], function (registersuite, assert, require, topic, test) { test.prototype.timeout = 60000; ... }
this should change timeout 1 minute instead of 30s, prevent test timing out.
Comments
Post a Comment