Test

作者 get-convex6ca54f6e2e75无许可证6 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Generate tests for Convex functions with convex-test (queries/mutations/auth/scheduling, in-memory). TRIGGER when the user wants tests / a test suite for their Convex backend / 'how do I test this'.

AI 生成的概览

使用内存版 convex-test 库为 Convex 后端函数生成 vitest 测试套件。

功能
指导智能体使用 convex-test 和 vitest 针对内存后端为 Convex 查询和变更编写测试。涵盖通过 t.run 填充数据、调用 t.query 和 t.mutation、断言参数与返回值、使用 withIdentity 测试鉴权路径、错误路径、索引,以及通过 t.finishInProgressScheduledFunctions 测试定时函数。产出确定性的测试文件以及运行 vitest 的说明。
适用场景
当用户需要为 Convex 后端编写测试或测试套件,或询问如何测试 Convex 函数时使用。适用于已使用 Convex 和 vitest、需要覆盖鉴权、错误和定时行为的项目。
运行要求
需要安装 convex-test 和 vitest 包,并具备带 schema 的 Convex 项目。该技能不附带脚本,仅为说明文档。测试应在内存中运行,无需实时部署、真实时间或网络访问。

Generate Convex tests

Use convex-test + vitest to test functions against an in-memory backend: args/returns, auth paths, indexes, and scheduled functions.

Steps

  1. Install convex-test + vitest.
  2. Write tests using convexTest(schema): seed via t.run, call t.query/t.mutation, assert.
  3. Cover auth (withIdentity), error paths, and scheduled functions (t.finishInProgressScheduledFunctions).
  4. Run vitest; keep tests deterministic.

Rules

  • Use convex-test (in-memory), not a live deployment.
  • Cover auth + error paths, not just the happy path.
  • Keep tests deterministic (no real time/network).

来源与署名

来源:get-convex/convex-backend-skill位于skills/test提交6ca54f6

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架