node.js - Test dies after XHR Post request -


i testing web page need create teacher account , other treatment it. create teacher account created custom command sends post request service using js object , run other functions continue configuration of account. problem having once xhr command run, test hangs , doesn't else though have other steps after , don't have pauses in code. before used instead of hanging there test finish without running of following steps after xhr request , wouldn't give me errors.

i think it's asyncronous nature of javascript , nightwatch js im not expert on insights on appreciated!

here custom command:

    exports.command = function (client) {          var stringutils = require("../utils/stringutils");         var data = client.globals;         // var email = stringutils.createrandomstring() + '@mailinator.com';         var email = data.teacheraccountcreation.email;         var userobj = {};         userobj["first-name"] = data.teacheraccountcreation.name;         userobj["last-name"] = data.teacheraccountcreation.lastname;         userobj.email = email;         userobj.emailconfirmation = email;         userobj.password = data.teacheraccountcreation.pwd;         userobj.passwordconfirmation = data.teacheraccountcreation.pwd;          var async = true;         var xmlhttprequest = require("xmlhttprequest").xmlhttprequest;         var request = new xmlhttprequest();         var url = "www.theurlwiththeservice.com";         var method = "post";           request.onload = function () { // in case want response              var status = request.status; // http response status, e.g., 200 "200 ok"             var data = request.responsetext; // returned data, e.g., html document.             console.log(status);             console.log(data);           },          request.open(method, url, async);         request.send(json.stringify(userobj));         return this;      }; 

and here call it:

module.exports = {   before : function(client){     var data = client.globals;      client       .deletecookies()       .url(data.classroomurl)        .createteacheraccountxhr(client) //this custom command hangs        .performlogin(data.teacheraccountcreation.email,data.teacheraccountcreation.pwd)       .submitregistrationform(client);    }, 

here console output when run it:

> [math pretest / 01 math pretest level] test suite > ===================================================== >  > running:  given new k level student 200 > {"email":"fr.test_1505336246966@mailinator.com","focusmode":false,"lastemailsentat":null,"cleverteacherid":null,"createdat":"2017-09-13t20:57:48.025763z","sciencepremiumuntil":null,"environment":null,"lastname":"test","mathunlimitedassessmentsuntil":null,"elaunlimitedassessmentsuntil":null,"mathassessmentassignmentcredits":30,"socialstudiespremiumuntil":null,"lastprintablegeneratedat":null,"teammode":false,"schoolid":null,"numreferrals":0,"role":null,"paidlessonsgrade":null,"emailverified":false,"firstname":"teacher","googleonly":false,"id":402,"numemailssent":0,"paidlessonsuntil":null,"updatedat":"2017-09-13t20:57:48.025763z","deletedat":null,"canchangeemail":true,"numprintablesgenerated":null,"mathpremiumuntil":null,"elapremiumuntil":null} 

so see browser opening url need see 200 response service , nothing else happens.

if have clues on im doing wrong here please let me know. in advance!


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -