rjz / supertest-session

Persistent sessions for supertest
Other
88 stars 21 forks source link

Missing documentation for manipulating session BEFORE calling methods #8

Closed brugnara closed 9 years ago

brugnara commented 9 years ago

This is the how to do, hoping that will be putted into documentation:

    var session = new Session();
    // here we are setting the session value
    session.app.request.session = {
      user: {
        account: {
          username: USERNAME
        }
      }
    };
    session
      .post(util.format(urlAnsw, _id, 'FAKEUSER'))
      .expect(400)
      .expect('Content-Type', /json/)
      .end(function(err, res) {
        res.body.should.have.property('ok', false);
        res.body.err.should.be.exactly('Username is not the one online from this IP.');
        session.destroy();
        done();
      })
rjz commented 9 years ago

Thanks, @brugnara! Would you be willing to open a pull request containing with a test for the expected behavior?

brugnara commented 9 years ago

This works with express but not with connect. I'm trying to add the test case but I'm unable to get session.app.request object. Any hints? If not, adding a new express_spec.js could be something you will like?

Thanks in advice.

brugnara commented 9 years ago

Just forget this. The session can be setted the way I wrote using express, without this module. Sorry about that.

rjz commented 9 years ago

Ah, no worries! Thanks for taking a look (and happy testing!)