TTC
Theo's Typesafe CultJudgeJLo
Issues with Clerk and Unit testing
I am working on a project for work and we have a strict requirement for unit tests. I decided to go with Vitest and we're using Clerk for auth. I ran into two different issues and I'm not sure which path is easier to solve. When I run the test (one so far) using the render method from @testing-library/react I get an error that "AuthContext not found". That made sense so I used a pattern I've used elsewhere of making a wrapper for render that wraps all children in a ClerkProvider.
When I do that I get a new error that says
ClerkProvider.js 2 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "@clerk/nextjs" asking them to ship the file in .mjs extension or add "type": "module" in their package.json.
I'm unsure how to proceed as the only issue I currently have with Clerk is that they have zero guidance on how to set up any tests within the auth context. Hoping someone has encountered this and has a pointer towards a solve.Solution
J
JudgeJLo•11d ago
SOLVED: After talking with Clerk it seems that two things were necessary. I needed to use the require syntax to import the Clerk provider in my wrapper, and I needed to pull in the AppRouterContext as well.
21KMembers
View on DiscordWant results from more Discord servers?
More PostsDrizzle + SQLite updated at fieldIs the only way to have an updated at field in SQLite just setting the updated at by hand on each upHow can I replicate the vanilla behavior of NextJS API routing in T3 stack?I am currently working on a project in which i would like to have my server side requests to an endpWhat is this app?this works but nope?I'm new to Suspense, this works great but I get the error: Did you forget to use 'await'?
It works,Micro Front End best practicesHello! I recently landed a job within a stack centered around micro front ends (react + node), whichUsing Turso in T3-CreateHi,
I am trying to use Turso for T3. I am using drizzle. The connection .env is slightly different