Cannot read property 'status' of undefined
See original GitHub issueWhen sending test request with expected status code and getting response with invalid content type (eg. header says application/json, but server sends xml/html), the Test.prototype._assertStatus
fails while getting status from res (which is undefined).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:50
- Comments:40 (2 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'status' of undefined in reactjs
The reason why you cant read data.status is that data is undefined. To get the data and the status, you need to return...
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
What Causes TypeError: Cannot Read Property of Undefined ... Undefined means that a variable has been declared but has not been assigned a...
Read more >TypeError: Cannot read property 'status' of undefined
I have performed the following steps within my Google Cloud Shell: npm i @codahq/packs-sdk -g.
Read more >Cannot read property 'status' of undefined · Issue #352 - GitHub
When sending test request with expected status code and getting response with invalid content type (eg. header says application/json, ...
Read more >TypeError: Cannot read property 'status' of undefined on Get
I'm getting the weird error and I don't know why. I'm just doing a get request, I'm doing another one in the same...
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 got this error when testing over a secure connection. I fixed it by adding NODE_TLS_REJECT_UNAUTHORIZED=0 as an env var on the test run.
For those wondering why this happens, it can happen because ‘127.0.0.1’ is not listed as a valid IP in your certificate. The underlying error is … Hostname/IP doesn’t match certificate’s altnames: "IP: 127.0.0.1 is not in the cert’s list: " However, you will not see this error message - Just the spurious and much disliked …
Cannot read property ‘status’ of undefined
Hope this helps someone. God bless.
Just got this error, and my problem is that I forgot the slash in get path:
supertest(server).get('favicon.ico')
gets me…putting the slash in,
supertest(server).get('/favicon.ico')
…the test works as expected.I traced the issue down to logic that applies assertions. It’s supposed to early-exit with an error if there was an error, but something causes it to run the assertions anyway and it fails because response is undefined when there’s an error:
Maybe it fails because the un-intended effect of forgetting the slash means that it will try to connect to “http://favicon.ico” which isn’t a server?
Either way it needs some logic hardened in
Test.assert
(or whatever runs through the array of assertions and applies them) and a friendly error message saying itCouldn't connect to http://favicon.ico:80 to run the tests
instead of throwing some IP number out - there is no way to know what that means without reading the whole library.