I have some non-trivial custom mutations that internally use several calls via OGM, and am trying to find the best approach to test. I have unit tests with mocked (via vitest-extended) mocks of the ogm.model(...) classes, and so can test things like expect(mocked.update).toHaveBeenCalledOnce(), as well as faking data returned from calls to .find(...)
However, there are some places where this is increasingly requiring knowledge of how the functions operate internally (as an example there are cases when a create and update will happen based on the existing data found), and I feel that some e2e tests would be more appropriate here. I have those setup, but they are hitting the main / local neo4j instance I'm using for dev. So my question:
- Have others setup either a simplified in memory graphql store for e2e tests? Or do people tend to just use a local instance (maybe having a dev and a test 'database' locally, if thats a thing in neo4j??)
- Or would spinning up a docker instance with neo4j in be better (these tests will be run infrequently, so am happy for some slow running testSetup / teardown)
- Or, could a neo4j sandbox be used? (feels technically yes, but cant find any API to create / terminate / or anything to say if this is considered 'ok' from a fair use PoV...)
- Or, are there stores I could use that would achieve this? I stumbled across neo4j-in-memory-serverbut haven't played with it.. and graphql-mocks/Paper seems to be aiming at the same problem..
Anyway, felt unlikely I was the first to try and tackle this..