Testng JavaScript callbacks -


i fear not understand javascrpt variable scoping. have function looks this:

return {   response: '',    birthmonthprompt: function(question, promptcallback) {     this.dialogtext = question;   } }; 

the idea birthmonthprompt ask user birth month. after enter it, have value 'november'. test ths, i've written following:

it('should prompt user', function() {   var reponse = 'november';   myservice.response= response;    myservice.birthmonthprompt('please choose birth month:',      function(userresponse) {     expect(userresponse).tobe(this.response);     }   ); }); 

when execute this, error says:

referenceerror: can't find variable: response 

i don't understand why test can't find response. doing wrong?

you have typo:

var reponse = 'november'; 

should be:

var response = 'november'; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -