question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when calling https on locahost I get "Cannot read property 'status' of undefined"

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
roytscommented, Sep 25, 2016

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.

1reaction
nathanhornbycommented, Apr 2, 2017

process.env.NODE_TLS_REJECT_UNAUTHORIZED = ‘0’;

Fixed it for me, thanks! Maybe SSL could be a boolean option passed in somewhere?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found