But most of the time, the tests fail with neo4j._exceptions.BoltHandshakeError: Connection to localhost:7687 closed without handshake response (not always though) which makes me think that neo4j is not totally initialized when tests start, but I have no clue how to check this hypothesis and fix it if it turns to be true.
It might be a bit late, but I had the same issue as you and managed to solve it. In my case it was due to the tests running before the neo4j DB was fully initialised. The solution was to set some healthchecks to be sure the DB is ready before running the test command:
Another unrelated issue in your example is that you are using postgres instead of neo4j when trying to resolve the port number: NEO4J_URI: "bolt://localhost:${{ job.services.postgres.ports[7687] }}"
Thank you so much for your answer! The problem was actually never totally solved, I used some ugly workarounds to make it work but will experiment with your solution in the coming days.