Skip to content

Destroy doesn't terminate server - port blockedΒ #18

@przemyslaw-maslowski

Description

@przemyslaw-maslowski

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions