You can use zombie + mocha to test this ....Zombie opens up a virtual browser fron tthe backend (which you dont see ) and clicks on any link on the page and then test this result by asserting using mocha . login to facebook before you start the application and then the link which fb authentication and assert for the new route(because you would have success redirection url) using zombie . Lets say the redirection url after successful login is /auth/facebook/success and /auth/facebook be the url where the login is tested . HERe is the code that could achieve it
var assert = require('assert'),
virtualBrowser = require('zombie');
describe('facebbok Login test', function () {
describe('Checking whether login is successfull based o nthe redirection URL', function () {
it('Checking for the sucess URL', function (done) {
virtualBrowser.visit('http://127.0.0.1:3000/auth/facebook', function (err, browser) {
if (err)
throw err;
console.log('Zombie visited the page,page loaded ');
assert.equal(browser.location.pathname, '/auth/facebook/success');
//all your tests goes here
/*you'll be using this 'browser object in the callback for further tests */
done();
});
});
});
});
Run the test by running it against the mocha (will be present inside the node_module/mocha of the folder of the installed module )
~/node_modules/mocha/bin/mocha ./zombie-test/test_sign_facebook.js
If mocha reports timeout since the login might be slow , just add more threshhold test time by using -t parameter
~/node_modules/mocha/bin/mocha -t 12000 ./zombie-test/test_sign