Testing with Mocha and Super test: Uncaught error outside test suite

本秂侑毒 提交于 2019-12-13 02:58:29

问题


While testing my api endpoints using mocha and supertest I got some of my test passing and some are not. The error message I got was uncaught error outside test suite: Uncaught error: listen EADDRINUSE:::5000


回答1:


Even I have faced same issue. This is because supertest keep on listening port even after completing the execution of test cases. So, run the mocha command with --exit flag. Before running npm test make sure there is no service running on the specified port

...
"scripts": {
     "start": "node server.js",
     "test": "mocha --exit"
 },
...


来源:https://stackoverflow.com/questions/52292791/testing-with-mocha-and-super-test-uncaught-error-outside-test-suite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!