Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
15 changes: 15 additions & 0 deletions test/supertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down