I'm looking for a way to overcome the Error: self signed certificate in certificate chain for the tests when I try to set up Next.js page tests with next-page-tester.
Network Error
at createError (node_modules/axios/lib/core/createError.js:16:15)
at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:84:14)
at XMLHttpRequest.invokeTheCallbackFunction (node_modules/jsdom/lib/jsdom/living/generated/EventHandlerNonNull.js:18:28)
at XMLHttpRequest.<anonymous> (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:35:32)
at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:338:25)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3)
at XMLHttpRequestImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9)
at fireAnEvent (node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36)
at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:130:3)
at Object.dispatchError (node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:59:3)
at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18)
at Request.onRequestError (node_modules/request/request.js:877:8)
console.error
Error: Error: self signed certificate in certificate chain
at Object.dispatchError (C:\Users\leoniecg\Projects\OneCustomerFrontend\frontend\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:62:19)
at Request.<anonymous> (C:\Users\leoniecg\Projects\OneCustomerFrontend\frontend\node_modules\jsdom\lib\jsdom\living\xhr\XMLHttpRequest-impl.js:655:18)
at Request.emit (events.js:327:22)
at Request.onRequestError (C:\Users\leoniecg\Projects\OneCustomerFrontend\frontend\node_modules\request\request.js:877:8)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketErrorListener (_http_client.js:469:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) undefined
I have dotenv installed, it works ok with the NODE_TLS_REJECT_UNAUTHORIZED=0 setting in the development environment, but even if I manage to read process.env settings into the test environment, i.e. I can see it with the console.log when I print it at the very top of a test file, I still get the error. Has anyone had this issue? I've been able to read .env.local file:
//.env.local
NODE_TLS_REJECT_UNAUTHORIZED=0
with the instructions given for example here: Using dotenv with Jest.
NODE_TLS_REJECT_UNAUTHORIZED=0 setting is a popular one to even start having Next.js on the localhost, so I guess someone has already stumbled upon this.
Or maybe I should forget about next-page-tester and use Cypress?