Hey! The current best practice for using queries in unit tests is stubbing the queries (which I assume you are already using since you linked to the unit test documentation). For complex logic, one common pattern is keeping the actual logic in a function that contains no ontology queries so that function can be tested independently of the queries.
That being said, there is an emulator feature in development that will allow you to mimic a the behavior of queries within a unit test. This emulator will use the data created in your unit test and most queries will just work like you would expect (there will be some functionality that will still require stubbing such as fuzzy searches). This feature should be later this year or early next year.