diff --git a/lib/response.js b/lib/response.js index 87aced7a..2e8d219a 100644 --- a/lib/response.js +++ b/lib/response.js @@ -596,7 +596,7 @@ function patch(Response) { assert.number(code, 'code'); this.statusCode = code; - return code; + return this; }; /** diff --git a/test/response.test.js b/test/response.test.js index 373bc214..dde7d7b6 100644 --- a/test/response.test.js +++ b/test/response.test.js @@ -760,3 +760,15 @@ test('GH-1791: should send NaN as null with application/json', function(t) { t.end(); }); }); + +test('GH-1851: res.status should be chainable', function(t) { + SERVER.get('/418', function(req, res, next) { + res.status(418).json({ teapot: true }); + }); + + CLIENT.get(join(LOCALHOST, '/418'), function(err, _, res, data) { + t.equal(res.statusCode, 418); + t.ok(data.teapot); + t.end(); + }); +});