Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
royts opened this issue Aug 30, 2016 · 9 comments

Comments

@royts
Copy link

royts commented Aug 30, 2016

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.

@equicolor
Copy link

+1

1 similar comment
@piemme
Copy link

piemme commented Sep 23, 2016

+1

@royts
Copy link
Author

royts commented 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.

@mikelax
Copy link
Contributor

mikelax commented Oct 28, 2016

@royts do you want to upgrade to 2.0.1 and see if that resolves the issue?

@cagdastulek
Copy link

+1

Having same issue after upgrading from 1.0.1 to 2.0.1 without any code changes.

Neither NODE_TLS_REJECT_UNAUTHORIZED nor 2.0.1 helps.

@jlindsay
Copy link

jlindsay commented Jan 9, 2017

+1
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0' does does help.

at Test.< anonymous > (src/xxxxx.js:81:29)
at Test.assert (node_modules/supertest/lib/test.js:156:6)
at assert (node_modules/supertest/lib/test.js:127:12)
at node_modules/supertest/lib/test.js:124:5
at Test.Request.callback (node_modules/superagent/lib/node/index.js:687:12)
at ClientRequest. (node_modules/superagent/lib/node/index.js:639:10)
at TLSSocket.socketErrorListener (_http_client.js:265:9)
at connectErrorNT (net.js:996:8)

@nathanhornby
Copy link

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

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

@bkeepers
Copy link

#446 should help reveal the underlying error here.

@mikelax
Copy link
Contributor

mikelax commented May 13, 2018

V3.1.0 has been published which includes #446 to solve handling for this error case.

@mikelax mikelax closed this as completed May 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants