title: NodeJS supertest access to session object
body: <p>I'm testing my Node.js application with supertest. In my controller I access the session object. In order to make a valid request this session object needs to be filled with some data.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>        // determine whether it is user's own profile or not
          var ownProfile = userId == req.session.user._id ? true : false;
  </code></pre>
  
  <p><strong>Test</strong></p>
  
  <pre><code>it('profile', function (done) {
      testUserOne.save(function(error, user){
  
          request
              .agent(server)
              .get('/profile?userId=' + user._id)
              .expect('Content-Type', /html/)
              .expect(200)
              .expect(/Profile/)
              .end(done);
      })
  });
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>How can I mock the req/session object?</p>