when calling https on locahost I get "Cannot read property 'status' of undefined"
See original GitHub issueHi,
here is my test code:
var request = require('supertest');
describe("test", function () {
it("should pass", function (done) {
request("https://localhost:8443")
.post("/path")
.send({})
.expect(200)
.expect({status: 'success'}, done);
});
});
when I run it get the error:
TypeError: Cannot read property 'status' of undefined
at Test._assertStatus (node_modules/supertest/lib/test.js:247:10)
at Test._assertFunction (node_modules/supertest/lib/test.js:265:11)
at Test.assert (node_modules/supertest/lib/test.js:153:18)
at assert (node_modules/supertest/lib/test.js:131:12)
at node_modules/supertest/lib/test.js:128:5
at Test.Request.callback (node_modules/superagent/lib/node/index.js:587:12)
at ClientRequest.<anonymous> (node_modules/superagent/lib/node/index.js:539:10)
at TLSSocket.socketErrorListener (_http_client.js:306:9)
at emitErrorNT (net.js:1272:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
while with curl I get a valid answer:
curl -d "" https://localhost:8443/path -k
the answer:
{"status":"success"}%
any idea what am I doing wrong?
btw - I’m using latest version (2.0.0)
thanks.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
when calling https on locahost I get "Cannot read property ...
Hi, here is my test code: var request = require('supertest'); describe("test", function () { it("should pass", function (done) ...
Read more >Error: cannot read property 'get' of undefined - HTTPS in node.js
the HTTPS request is in the getJSON method so if you run data.js and no one is calling getJSON it doesnt mean the...
Read more >Resolving the JavaScript Promise Error "TypeError: Cannot ...
TypeError - Cannot read property 'then' of undefined is thrown when the caller is expecting a Promise to be returned and instead receives ......
Read more >Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >cannot read properties of undefined (reading 'post') axios
I am trying to implement an axios request inside an express app to query an external API. I looks fine but when I...
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
Putting
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
before the test solved it for me.I’ll create a pull request to add it to the docs.
Fixed it for me, thanks! Maybe SSL could be a boolean option passed in somewhere?