Expect Status with `done()` isn't working
See original GitHub issue.expect(404, done)
doesn’t seem to be failing if the response is actually 200. Not sure if I’m doing something wrong, or if I’ve found a bug?
http://stackoverflow.com/questions/37729206/supertest-expect-not-asserting-status-codes-correctly
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Expect Status with `done()` isn't working · Issue #345 - GitHub
it('should handle an 404 response in expect callback', function (done) { request(app) .get('/doesntExist') .timeout(1) .expect(404, function ( ...
Read more >node.js - Supertest Expect Not Asserting Status Codes Correctly
The line of code that isn't working is .expect(404, done) if I change this to be .expect(200, done) then the test doesn't fail....
Read more >Expect - Jest
When you're writing tests, you often need to check that values meet certain conditions. expect gives you access to a number of "matchers" ......
Read more >HTTP/1.1: Status Code Definitions
A client MUST be prepared to accept one or more 1xx status responses prior to a regular response, even if the client does...
Read more >405 Method Not Allowed - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 405 Method Not Allowed response status code indicates that the server knows the request method, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m running
supertest 2.0.0
and copying the exact code pasted here: https://github.com/visionmedia/supertest/issues/345#issuecomment-229496425Both tests pass, so it seems like a breaking change was introduced in 2.0.0, maybe i’m missing something in the docs, but i’m not sure what to do to test the status code
so to work around this i add an end function:
I have the same problem:
This doesn’t fail:
while this fails: