jest-preset-angular: Jsdom 13 error connect ECONNREFUSED 127.0.0.1:80 even all test passed
hi team. I’m new to Jest and try to add it to my Angular app. For now, all the test is passed but this error is repeatedly produced. Seem like jest does not mock the http request or jsdom can not handle http mocking. Can anyone help me out? I tried to research but can not find any solution.
console.error node_modules/jest-environment-jsdom-thirteen/node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: connect ECONNREFUSED 127.0.0.1:80
at Object.dispatchError (D:\EMP-APP\node_modules\jest-environment-jsdom-thirteen\node_modules\jsdom\lib\jsdom\living\xhr-utils.js:60:19)
at Request.client.on.err (D:\EMP-APP\node_modules\jest-environment-jsdom-thirteen\node_modules\jsdom\lib\jsdom\living\xmlhttprequest.js:674:20)
at Request.emit (events.js:198:15)
at Request.onRequestError (D:\EMP-APP\node_modules\request\request.js:881:8)
at ClientRequest.emit (events.js:193:13)
at Socket.socketErrorListener (_http_client.js:397:9)
at Socket.emit (events.js:193:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:81:17) undefined
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19
This is what I’m using for my jest.config.js file:
Take a look at my comment here for the full explanation: https://github.com/thymikee/jest-preset-angular/issues/286#issuecomment-519050423
@wtho I have been receiving this error myself but I think it is environment based. I recently ported over my company’s CI from Jenkins to Github Actions. While the tests passed fined this error does pop up. I’ve been trying to figure it out but to no avail.
● Console
@jackmercy , the way I fixed mine was taking a step back and creating a new
setup.jest.tsbased on the defaults specified on the documentation. Then adding item by item to check what was breaking.In my case, I end up realising that
jest-preset-angularsits on top ofts-jestand it’s logic it’s all around setting upts-jestto work with Angular. If you check the source code, you can see what’s the default preset is.Then I started adding the preset values and it all worked out. You can check my repo setup. There’s not much but it has libraries added with tests. Jest is configured to get code coverage and html reports to be used on CI/CD pipeline and the results are also used within Storybook.
Let me know if you need any clarification 😃