当我尝试使用next-page-testerError: self signed certificate in certificate chain设置 Next.js 页面测试时,我正在寻找一种克服测试的方法。
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
我安装了dotenv,它NODE_TLS_REJECT_UNAUTHORIZED=0在开发环境中的设置可以正常工作,但即使我设法将process.env设置读入测试环境,即当我在最顶部打印时,我可以在 console.log 中看到它的测试文件,我仍然得到错误。有人遇到过这个问题吗?我已经能够读取.env.local文件:
//.env.local
NODE_TLS_REJECT_UNAUTHORIZED=0
使用此处给出的说明:Using dotenv with Jest。
NODE_TLS_REJECT_UNAUTHORIZED=0设置是一个流行的设置,甚至开始在本地主机上安装 Next.js,所以我想有人已经偶然发现了这一点。
或者也许我应该忘记 next-page-tester 并使用 Cypress?