Fork me on GitHub
#pathom
<
2021-12-25
>
jherrlin10:12:25

Happy holiday! Really happy that I finally got time to test out Pathom! I've made a couple of resolvers and got the basics to work. Now I wonder how to reason about resolvers and actions (side effecting stuff). I would like to unit test my resolvers and have come up with this. I assoc a function to each resolver map and that function will be used inside the resolver to return data. In production this functions may do a database or http request. But in the test suite it returns static (or generated) data. Is this a good way to do this? Are there dangerous things I missed?

Drew Verlee19:01:11

you can call your resolver like regular functions, so the same concepts apply for testing.

Drew Verlee19:01:16

That means you have consider the trade off in calling the "side effect" the reason people tend to mock it is because there is to high a cost. But thats a guideline not a rule.