EvaE
Convex Community14mo ago
6 replies
Eva

Testing `withIdentity` in `convex-test`

Hello! I've created a custom mutation for userMutation and a custom query for userQuery which use getAuthUserId to pass along the current userId and verify that a user is authenticated. I then use these custom mutations and queries whenever I want one of my Convex functions to run with authentication for the current user.

I want to write tests for these queries and mutations, and I understand I can use t.withIdentity to mock a user account. How can I get the mock
id
from the withIdentity user? When I try accessing it, I get a typescript error that the mocked user's
id
doesn't exist on Id<"users">.
Was this page helpful?