Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Pass `this` to end() callbacks #86

Merged
merged 1 commit into from Dec 1, 2013

Conversation

Projects
None yet
2 participants
Contributor

bajtos commented Nov 29, 2013

The change allows developer to access the Test object and its properties like url from the callback passed to .end(). This is useful when the request URL is constructed dynamically using a random server port.

Example:

request(app)
  .get('/foo/bar')
  .end(function(err, res) {
    if (err) return done(err);
    var remoteOrigin = url.resolve(this.url, '/');
    res.body.originUrl.should.eql(remoteOrigin);
  });
Pass `this` to end() callbacks
The change allows developer to access the `Test` object and its
properties like `url` from the callback passed to `.end()`.
This is useful when the request URL is constructed dynamically using
a random server port.

Example:

  request(app)
    .get('/foo/bar')
    .end(function(err, res) {
      if (err) return done(err);
      var remoteOrigin = url.resolve(this.url, '/');
      res.body.originUrl.should.eql(remoteOrigin);
    });

gjohnson added a commit that referenced this pull request Dec 1, 2013

@gjohnson gjohnson merged commit e2b64b5 into visionmedia:master Dec 1, 2013

1 check failed

default The Travis CI build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment