Jest + SuperTest tests pass locally, but GitHub action CI has connect ECONNREFUSED
error. This seems to be an error caused by not connecting to the server.
When testing locally, I always tested after connecting to the server through npm run start:dev
. So, I want to be able to run the server in the CI stage to conduct tests, and then shut down the server.
However, when I type the command npm run start:dev && npm run test
, CI doesn't finish for tens of minutes after the server starts.
How can I make my tests run as successfully in the CI stage as I did locally? I need help. The execution environment is node js.
The code to create a request
variable and get the API call result is as follows.
const request = supertest("http://127.0.0.1:55503");
const response = await request.get("/test/a");