if I call my API in this way using Supertest 4.x:
return res.status(401).send()
and try to assert it in this way:
response = await request(app).post('/admin').send( { data_here } )
expect(response.status).toBe(401);
Supertest returns Unauthorized and not status code 401 as I'm expecting.
If I do the same thing using Supertest 3.x , it returns the status code I'm expecting to test it.
Is there a new way to do it on version 4.x ?
We used to set the expected status code, like 401, but that no longer returns the response, it throws the error instead.
Seems like a breaking change without documentation.
Same here, used this in 3.x:
await request(app)
.post('/system/invoice/generate')
.set('content-type', 'application/json')
.set('Authorization', 'invalidtoken')
.send()
.expect(httpStatus.UNAUTHORIZED)
Short migration guide would be nice
This may be a regression - see https://github.com/visionmedia/superagent/issues/1466
same and has been reported yesterday but still no fixes.
Don't you have any tests which cover these cases? I mean there was already something similar:
Don't you have any tests which cover these cases? I mean there was already something similar:
534
Feel free to open an PR and add those tests 馃憤
I鈥檝e started adding a few tests, the problem is all the tests use callbacks only, so the regression was overlooked, again (sorry!).
Just to be clear, my comment was in @akirilyuk s direction.
@SMenigat should not the person who created the fix also add the tests which verifies the error wont happen again? Also should it not be the maintainers job to have meaningful tests for their own product?
+1 with @akirilyuk
Thank you 馃檹
Most helpful comment
Same here, used this in 3.x:
Short migration guide would be nice