Skip to content

Best practice for mocking cache to test offline mutations? #1126

Answered by kitten
JohnAtFenestra asked this question in Q&A
Discussion options

You must be logged in to vote

So there isn’t really a full story for this because we’d assume that E2E tests would take better care of this. But given that you’re explicitly asking for unit tests you can actually mock the entire store: https://github.com/FormidableLabs/urql/blob/1569515539f7f859d2919fb8e5f4e5b439a3cf4e/exchanges/graphcache/src/index.ts#L3

You’ll notice that we left Store, query, and write exposed. These are all the primitive you’d need to mock Graphcache’s store without the entire exchange or client.

We don’t really have that documented as it’s technically part of the private API, but I don’t expect it changing a lot. Furthermore we do have our micro benchmarking code in the repo, which may give you a…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ginnymin
Comment options

Answer selected by JohnAtFenestra
Comment options

You must be logged in to vote
1 reply
@ginnymin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants