`convex-test` could not find the "_generated" directory
Just installed
convex-test
and wrote a very simple test at the root of my /convex
folder. Running it produces an error:
My _generated
directory is present and my convex functions are all in /convex
at the root of my project. Not sure what might be the issue.10 Replies
how does your package.json look like?
@Eva facing the same issue...how did you fix it?
I had the same issue and fixed it with this
In nextjs i get this error:
js Property 'glob' does not exist on type 'ImportMeta'.ts(2339)
nextjs shouldn't even be loading the test file, are you exporting anything from the test file that might be used in your nextjs code?
No I'm only doing imports in my test files
re:
Could not find the "_generated" directory
-- I think something about pnpm sometimes does not play nicely with convexTest
automatically finding your convex functions.
The workaround is what morvud described of passing in a import.meta.glob
(and I'll update the docs + error message to recommend this for pnpm).
To get import.meta.glob
to typecheck, I believe you want to add /// <reference types="vite/client" />
to the top of whatever file you're defining your glob in as shown in https://docs.convex.dev/testing/convex-test#custom-convex-folder-name-or-location (or in a pinch, add a // @ts-expect-error
comment above the line TypeScript is unhappy about)convex-test | Convex Developer Hub
The convex-test library provides a mock implementation of the Convex backend
That's correct, the advice in the docs now is what I did. Defining
test.setup.ts
:
And then importing modules
to use within the arguments of convexTest()
:
Would love if the library could be updated to avoid this for pnpm, definitely feels like extra boilerplate!