Convex-test and by_creation_time
Hello, when testing a function that uses the index "by_creation_time" , convex-test are failing and reporting an error. It looks like to me the code is valid, so I believe it's a convex-test issue:
Example:
Code
Test
Error while running tests
Just reporting the issue, thanks in advance if you fix it. Have a nice day Convex team 🙋♂️
3 Replies
Hi @Riki. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error message you're seeing suggests that the
by_creation_time
index is not declared in your schema for the notifications
table. While Convex automatically creates the by_creation_time
index and uses it for database queries that don't specify an index, it seems that this index might not be automatically available in the testing environment provided by convex-test
.
To resolve this issue, you could try explicitly declaring the by_creation_time
index in your schema for the notifications
table. Here's an example of how you might do this:
This will explicitly declare the by_creation_time
index in your schema, which should make it available for use in your tests.
If you continue to experience issues, I would recommend reaching out to the Convex support community for further assistance.
Sources:
- Database > Indexes > Limits (https://docs.convex.dev/database/indexes#limits)
- Functions > Testing > convex-test
library > Calling functions with t.query
, t.mutation
and t.action
(https://docs.convex.dev/functions/testing#calling-functions-with-tquery-tmutation-and-taction)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@145858609085939712> kapa.ai is still learning and improving, please let us know how it did by reacting below
Yep this sounds like it's a bug in convex-test. We'll look into it and report back
Should be fixed in convex-test@0.0.21