Open literallyMello opened 1 year ago
No, but what does the superset. disableTLSCerts()
do?
It stops supertest from checking the validity of the certificates so we you are using self-signed for local dev or hitting environments with otherwise non-legit certificates (like test environments). Without it supertest throws errors like Error: self signed certificate
(see for example https://github.com/ladjs/supertest/issues/737)
Ok, so the issue is that those errors aren't reported correctly, like the assertion error you mentioned? Can you post a stack trace?
Running Example Test:
───────────────────────────────────────────────────────────────────────────────────────────────────
→ Running [beforeEach]:
→ Completed [beforeEach].
→ Running command: request ('https://redactedUrlHere')
Error
uncaughtException: Cannot read properties of undefined (reading 'request')
TypeError: Cannot read properties of undefined (reading 'request')
at Test.<anonymous> (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/@nightwatch/apitesting/nightwatch/commands/supertest/request.js:33:71)
at Test.assert (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/supertest/lib/test.js:172:8)
at localAssert (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/supertest/lib/test.js:120:14)
at fn (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/supertest/lib/test.js:125:7)
at Test.callback (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/superagent/src/node/index.js:924:3)
at ClientRequest.<anonymous> (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/superagent/src/node/index.js:836:10)
at ClientRequest.emit (node:events:513:28)
at ClientRequest.emit (node:domain:489:12)
at TLSSocket.socketErrorListener (node:_http_client:481:9)
at TLSSocket.emit (node:events:513:28)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
️TEST FAILURE (5.891s):
- 1 error during execution;
- 0 tests failed;
- 0/NA tests passed
When testing internal APIs with insecure/untrusted certificates I was getting error
when running a test similar to
until I thought to try using the .disableTLSCerts() option (the API under test int his scenario does not use a securely-signed certificate)
Unless I'm mistaken I recall SuperTest providing an error in these scenarios that would more easily let the user realize it didn't connect because of an insecure certificate. Is the plugin hiding the exception?