Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy doesn't terminate server - port blocked #18

Open
przemyslaw-maslowski opened this issue Sep 18, 2024 · 1 comment
Open

Destroy doesn't terminate server - port blocked #18

przemyslaw-maslowski opened this issue Sep 18, 2024 · 1 comment

Comments

@przemyslaw-maslowski
Copy link

I'm thinking about using this repo for testing and I've encountered a problem in Jest.
If I start tests by defining a postgres mock, by PostgresMock.create() then .listen() and later at the end of the tests end it with .destroy() (I don't think there's any other way to do it), then when I run the tests again (without ending the process) I get a message that the port is taken.

I reviewed the code and it seems to me that the problem is the server created in listen(), which is not closed by destroy().

My solution is to save the created server in some private variable and in the destroy() method end it with .close();.
I tested it locally and the solution releases the port, eliminating the problem.

@s-p-sathish
Copy link

@przemyslaw-maslowski before running again please kill the port use eg: npx kill-port 5432

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants