Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No clear way to interface with convex-auth #32

Open
mez opened this issue Dec 20, 2024 · 1 comment
Open

No clear way to interface with convex-auth #32

mez opened this issue Dec 20, 2024 · 1 comment

Comments

@mez
Copy link

mez commented Dec 20, 2024

I can do the following in my test:

      const ctx = t.withIdentity({ id: userId.toString(), tokenIdentifier: "test" });

but const userId = await getAuthUserId(ctx); call from inside a convex function being tested doesn't seem to return the correct userId created in the test.

@mez
Copy link
Author

mez commented Dec 20, 2024

I got it working by mocking the convex auth module like the following:

// Mock the auth module
vi.mock("@convex-dev/auth/server", async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    getAuthUserId: vi.fn(),
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant