supertest
supertest copied to clipboard
Self signed certificate issue
Hello everyone and thank you for reading. I'm testing an API (Internal) that calls another API (external), and processes the results. When I test methods that don't use the external, everything is fine. When I call it via postman, the problematic method it works perfectly. But, when I call it via SuperTest I get
Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1514:34)
at TLSSocket.emit (events.js:400:28)
at TLSSocket._finishInit (_tls_wrap.js:936:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:708:12) {
code: 'DEPTH_ZERO_SELF_SIGNED_CERT',
I've tried setting
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
and
"jest": {
"testEnvironment": "node"
}
without success.
Any ideas? I don't know what to do next.
Thank you all again.
Hi,
old issue, but for me it works using trustLocalhost
for request("https://localhost")
, e.g.:
describe("GET /", function(){
it("gets index", function(){
return req
.get('/')
.trustLocalhost(true)
.expect('Content-Type', /html/)
.expect(200);
});
});
node: v16.7.0 supertest: v6.3.1 mocha: v10.1.0