supertest
supertest copied to clipboard
Set Authorization header to get request
Versions: "supertest": "6.0.1",
Code example:
it('should fail getting all users, reason role = user', async () => {
const authHeaders = {Authorization: 'test'}
await request(app)
.get('/user/all')
.set(authHeaders)
.expect(({ headers }) => {
console.log(headers);
})
.expect(HttpStatus.NOT_FOUND);
});
Actual behavior: header is missing.
Expected Behavior: authheader to be part of the headers body
Reproducible on Node v14.15.2
Is not reproducible on v12.20.0
Versions: "supertest": "6.0.1",
Code example:
it('should fail getting all users, reason role = user', async () => { const authHeaders = {Authorization: 'test'} await request(app) .get('/user/all') .set(authHeaders) .expect(({ headers }) => { console.log(headers); }) .expect(HttpStatus.NOT_FOUND); });Actual behavior: header is missing.
Expected Behavior: authheader to be part of the headers body
See https://github.com/visionmedia/supertest/issues/693#issuecomment-785052983
same for me, I cant attach any header
Versions: "supertest": "6.0.1",
Code example:
it('should fail getting all users, reason role = user', async () => { const authHeaders = {Authorization: 'test'} await request(app) .get('/user/all') .set(authHeaders) .expect(({ headers }) => { console.log(headers); }) .expect(HttpStatus.NOT_FOUND); });Actual behavior: header is missing.
Expected Behavior: authheader to be part of the headers body
did you find a solution?