forwardemail / forwardemail/supertest
expect called multiple times with redirects
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
Consider the following example:
```js
request.
agent(BASE_URL).
get('/openid/auth').
query({
client_id: 'foo',
scope: 'openid',
response_type: 'code',
redirect_uri: 'http://127.0.0.1:8000/api/auth/token'
}).
redirects(1).
expect(res => {
console.log(res.headers);
}).
end(err => err ? done.fail(err) : done());
```
NOTE: `GET /openid/auth` redirects to `/interaction/quux`
Output:
```
{ 'x-powered-by': 'Express',
'content-type': 'text/html; charset=utf-8',
'content-length': '3881',
etag: 'W/"f29-ybkVuY3JwqeiApimGOkpyRwNFc8"',
date: 'Wed, 29 Aug 2018 09:52:42 GMT',
connection: 'close' }
{ 'x-powered-by': 'Express',
'content-type': 'text/html; charset=utf-8',
'content-length': '3881',
etag: 'W/"f29-ybkVuY3JwqeiApimGOkpyRwNFc8"',
date: 'Wed, 29 Aug 2018 09:52:42 GMT',
connection: 'close' }
```
However, if rewrite the snippet to following:
```js
request.
agent(BASE_URL).
get('/openid/auth').
query({
client_id: 'foo',
scope: 'openid',
response_type: 'code',
redirect_uri: 'http://127.0.0.1:8000/api/auth/token'
}).
redirects(1).
end((err, res) => {
if (err) return done.fail(err);
console.log(res.headers);
done();
})
```
Output:
```
{ 'x-powered-by': 'Express',
'content-type': 'text/html; charset=utf-8',
'content-length': '3881',
etag: 'W/"f29-SCVYrJWiUa611NIoPcK1Xx/Vexk"',
date: 'Wed, 29 Aug 2018 09:58:25 GMT',
connection: 'close' }
```
Question: Is it a normal behaviour for expect with redirects?
Contributor guide
Assessment
This issue has not been assessed yet.