It depends on how you implemented your sessions.
In my Sails application, after authentication, I set req.session.authenticated = true , as well as cookies, etc. One thing you can do if you do something like this is in your /login route, add:
if (process.env.NODE_ENV === 'test') { req.session.authenticated = true; // do what you would do next after authentication } else { // do normal login procedures }
Then, in your tests, in before hook, you can use superagent to request a trace /login for authentication:
describe('MyController', function() { var agent; before(function (done) { agent = require('superagent').agent('YOUR_APP_URL');
This is just an idea - you can adapt this approach despite the fact that you are checking sessions. This works for my Sails application, using Mocha for testing.
source share