diff --git a/lib/test.js b/lib/test.js index f8300881..59320e54 100644 --- a/lib/test.js +++ b/lib/test.js @@ -275,7 +275,7 @@ class Test extends Request { */// eslint-disable-next-line class-methods-use-this _assertHeader(header, res) { const field = header.name; - const actual = res.header[field.toLowerCase()]; + const actual = res.headers[field.toLowerCase()]; const fieldExpected = header.value; if (typeof actual === 'undefined') return new Error('expected "' + field + '" header field'); diff --git a/test/supertest.js b/test/supertest.js index 87acf58d..0050b0a2 100644 --- a/test/supertest.js +++ b/test/supertest.js @@ -774,6 +774,21 @@ describe('request(app)', function () { }); }); + it('should not be affected by content-type params that shadow header property', function(done) { + const app = express(); + + app.get('/', function (req, res) { + res.setHeader('foo', 'a'); + res.setHeader('content-type', 'text/csv; header=present'); + res.end(); + }); + + request(app) + .get('/') + .expect('foo', 'a') + .end(done); + }); + describe('handling arbitrary expect functions', function () { let app; let get;