OccultSlolem
OccultSlolem2y ago

Testing queries, mutations, actions

What's a good approach for writing tests for Convex actions, queries, and mutations, especially when those tests are dependent on auth state?
2 Replies
Michal Srb
Michal Srb2y ago
We definitely want to provide a more straightforward testing setup in the future. For now you have to provide your own mocks for any context passed into functions. You could for example call a query from a test: export const myQuery = … // test.ts myQuery({auth: {getUserIdentity() { return { … }; }}}, {arg0: …} )
ian
ian2y ago
Ah, we raced in answering. @Michal Srb can you put your answer in the Forum so it's discoverable for others? I have a similar answer there but yours has the nice code https://discord.com/channels/1019350475847499849/1135351735368564796/1135351735368564796

Did you find this page helpful?