Failed to load url with convex-test
Hello, I'm trying to setup vitest and convex test but everytime I write a query or mutation I get a failed to load url error.
23 Replies
weirdly enough if I use the run function it seems to work fine? I just can't pass in my functions to the query or mutation procedures.
Ah. I bet this is because you nested the test file in a test folder.
I think for now you have to put all test files into the "top-level" convex/ folder.
I filed https://github.com/get-convex/convex-test/issues/6 to look at this more.
Ah I see thank you will give it a try tomorrow morning
even after moving my test to the top level of the convex folder it still seems to not work with my functions
I am using this within a nextjs project and utilizing vitest workspaces so I can have a different test enviroment for my convex and nextjs. If that could possibly be the issue.
That's probably it, as I haven't tried workspaces.
I see
Yep, I can repro
Ahh are there any recommended ways of testing in a nextjs project without workspaces then?
I think if you just delete the
vitest.workspace.ts
file everything will work?
The only difference is that you can't as easily run only one set of tests or the other?Hmm interesting well that's fine for now
thanks!
I'm looking into fixing this
awesome thank you
I've also run into this error twice, in two different projects
In one the test file was located in
test/here.test.ts
and the Convex functions directory was in test/convex
(atypical certainly), in the other the test was in src/convex/dir/otherDir/here.test.ts
(so, inside the Convex functions directory)Thank's @RJ, it's helpful to know! I'm confident I can get this and bunch of the other related issues with convex-test fixed.
Great, thanks @Michal Srb! Let me know if I can provide any more details/do any testing for you
Hi @Michal Srb , I'm experiencing some problems with
convex-test
. Specifically, whenever I run a test that imports import { api } from '@/convex/_generated/api'
I get the error shown in the screenshot. Seems to be some error in node_modules/convex-test/dist/index.js
, so I'm not sure how I can troubleshoot this.
It works fine if I run a simpler test that does not import api
but only imports import schema from '@/convex/schema'
@djbalin what versions of convex-test and convex do you have (
npm ls
). The newest version of convex-test had a peer dependency on a newer version of convex@lee
├─ convex-helpers@npm:0.1.56
├─ convex-test@npm:0.0.33
├─ convex@npm:1.16.3
Could that be the problem, that the newest Convex version is 1.16.6 and
test
depends on that?Yeah you need at least convex@1.16.4 . When you installed convex-test it should have printed an error that the peer dependency isn't satisfied
https://github.com/get-convex/convex-test/blob/main/package.json#L35 (it's also possible i don't understand peer dependencies or how they interact with pnpm)
GitHub
convex-test/package.json at main · get-convex/convex-test
Testing harness for pure-JS Convex tests. Contribute to get-convex/convex-test development by creating an account on GitHub.
I'm sure you understand it better than I do 😂 thanks man. Guess I should pay more attention to dependency warnings in the future!
Works now after updating convex, thanks man! ☺️