We have a REST API to reboot the HTTP server and then poll for it using another REST API to come back. While calling a REST API when web server is down, supertest gets an exception. You can see at the specific line that "res" is undefined because HTTP server is down. I think this code on line 202 needs to be modified to deal with this situation.
/home/psingh/applianceUpgrade/node_modules/supertest/lib/test.js:202
if (res.status !== status) {
^
TypeError: Cannot read property 'status' of undefined
at Test.assert (/home/psingh/applianceUpgrade/node_modules/supertest/lib/test.js:202:12)
It's been a while. Why this PR isn't getting merged?
I am planning to try and get the 1.1.0 release out next week.
I just tracked down this bug as well. We have a gulp task that starts our services and then runs functional tests. Due to a problem with our gulp task, the tests were running before the services finished starting. This was causing intermittent test failures with no clear reason for failure. Hoping this PR will expose the ECONNREFUSED error, which would have made debugging the problem much simpler.
@mikelax I can still reproduce this error as of 1.1.0 - running tests against an offline server (or the wrong port on an active server) always results in a pass, even if explicit expects are set.
@csvan I will update the tag for this issue. It just recently got merged into master but it was not part of the 1.1.0 release. You can try to check out master and see if that works for you.
I am going to bump this to version 1.2.0 as I would consider this a breaking change from current behavior.
Breaking changes should be 2.0, not 1.2.
But this seems like a bug fix, not something that's going to break actual uses. I may be wrong, but that's my gut-check.
@mikelax - Do you know ETA for this fix; or know if supertest is working towards a fix?
My issue is similar to this : https://github.com/visionmedia/supertest/issues/298
@csvan - did you find a fix for it?
hi @mikelax sorry to chime in with the others, but it's also occurring on 1.2. Just did a fresh install from npm (1.2) and have the same non-descriptive error message. The other issue, is that all the tests pass. Tried running from master and get the same message as well.
Any ideas or help needed?
There's another ticket open for the same issue - #314
Is there a workaround for this bug? All I get is the line [TypeError: Cannot read property 'status' of undefined], no stack trace, nothing usable to fix it.
Unlike the author of this thread, my server is definitely running. My code is:
tape(testeeName + 'creates new user in database', function (assert) {
supertest('http:0.0.0.0:3000/')
.post(testData.apiPrefix + "signup")
.send(testData.validUser)
.expect(200)
.expect('Content-Type', /json/)
.end(function (error, result) {
assert.end();
});
I am also still getting this issue. Tried a few node versions within 6, 7, and 8. For me it happens only when I attach two files to my supertest POST request
Most helpful comment
Is there a workaround for this bug? All I get is the line
[TypeError: Cannot read property 'status' of undefined], no stack trace, nothing usable to fix it.Unlike the author of this thread, my server is definitely running. My code is: