convex-test

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- GENERATED from convex-agents content/capabilities/test.json — do not edit by hand. -->
<!-- 由convex-agents的content/capabilities/test.json生成——请勿手动编辑。 -->

Generate Convex tests

生成Convex测试用例

Use convex-test + vitest to test functions against an in-memory backend: args/returns, auth paths, indexes, and scheduled functions.
使用convex-test + vitest针对内存后端测试函数:包括参数/返回值、认证路径、索引以及定时函数。

Workflow

工作流程

  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.
  1. 安装convex-test + vitest。
  2. 使用convexTest(schema)编写测试用例:通过t.run初始化数据,调用t.query/t.mutation,进行断言。
  3. 覆盖认证(withIdentity)、错误路径以及定时函数(t.finishInProgressScheduledFunctions)。
  4. 运行vitest;确保测试具有确定性。

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).
  • 使用convex-test(内存版),而非实时部署环境。
  • 覆盖认证和错误路径,不只是正常流程。
  • 确保测试具有确定性(不涉及真实时间/网络)。