i using package xolvio/meteor-cucumber , i'm trying call fixture method , use returned value in step definition:
step:
and fill in sms code "#smscodeverification"
step definition:
this.then(/^i fill in sms code "([^"]*)"$/, function (verificationfield, callback) { var code = this.server.call('getsmscodeforuser', "+467*******"); console.log("step code: " + code); this.client .waitforexist(verificationfield, 4000) .waitforvisible(verificationfield, 2000) .setvalue(verificationfield, code) .call(callback); }); the above code prints:
step code: [object promise]
the server method looks this:
'getsmscodeforuser': function (tel) { var user = user.findone({ phone: tel }), password = password.findone({ user: user._id }), code = parseint(password.code); return code; } the console log in step definition run before server method finished, , using meteors normal way of getting callback server methods not work, return undefined.
this.server.call('getsmscodeforuser', "+467*******").then(function(resopnse) { // can use response here });
Comments
Post a Comment