Error testing file upload
This is probably something stupid on my side... But maybe someone can help 🙂
I'm testing image upload with convex-test. For simplicity i just create a 100 Byte Blob like this:
However this throws the following error inside
store
function:
When I use the blob from a real image it works as expected:
Any idea what I'm doing wrong when creating the Blob data?8 Replies
Do you have the edge runtime configured as shown in step 3?
https://docs.convex.dev/functions/testing
Testing | Convex Developer Hub
Automating the testing of your Convex functions is easy.
No, i have probably vitest defaults. Let me try 🙂
Should the vitest config reside within /convex/ directory? I'm using vitest also for component tests of my frontend code, so my vitest.config.ts in root folder looks like this:
I see, you're already using the jsdom environment.
You'll probably need https://vitest.dev/guide/workspace.html but I know there is an issue with workspaces and convex-test
Vitest
Next generation testing framework powered by Vite
I can confirm the blob issue us resolved when using the vitest config according to docs. But using the edge-runtime for frontend tests probably is not what I want :-).
Or use this, that might be much simpler:
https://vitest.dev/guide/environment.html#environments-for-specific-files
Vitest
Next generation testing framework powered by Vite
Or even better: https://vitest.dev/config/#environmentmatchglobs
Vitest
Next generation testing framework powered by Vite
Yes, this sounds like a good solution. trying 🙂
Yes, it seems to work fine with this config: