node.js - Testing NodeJs with Mocha/Sinon - Sails -



node.js - Testing NodeJs with Mocha/Sinon - Sails -

i'm relatively new nodejs , sailsjs framework, , enjoy write code it, coming php background found testing nodejs bit weird.

i'm trying test mocha , sinon method login of authservice, beingness not expert need illustration on how accomplish successful test , unfortunately documentation online still bit poor illustration lots useful thanks!

login: function(username,password,callback) { user.findonebyusername(username, function(err,user){ // if has error if (err) { homecoming callback(err) } // if user not found username if (!user) { homecoming callback(err,false); } // if found match password bcrypt.compare(password, user.password, function (err, res) { if (!res || err) homecoming callback(err,false); homecoming callback(err,true,user); }); }); }

if can create lite on appreciated

check we.js illustration how setup tests:

link: https://github.com/wejs/we-example/tree/master/test ( "headless browser" tests )

for integration , unit tests supertest check: https://github.com/wejs/we/tree/emberjsdev/tests

node.js unit-testing sails.js mocha

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -