---
id: gh-convex-test
name: "convex-test"
url: https://skills.yangsir.net/skill/gh-convex-test
author: convex
domain: testing
tags: ["convex", "testing", "vitest", "unit-testing", "backend"]
install_count: 34900
rating: 4.60 (120 reviews)
github: https://github.com/convex/agent-skills/tree/main/skills/convex-test
---

# convex-test

> 为应用的 Convex 函数生成基于 convex-test 与 vitest 的测试：在内存后端中覆盖参数与返回值、鉴权路径、索引查询以及定时函数。该技能让开发者在本地快速获得确定性的后端测试，无需连接线上部署，从而更早暴露权限与边界缺陷。

**Stats**: 34,900 installs · 4.6/5 (120 reviews)

## Before / After 对比

### 为 Convex 函数补测试的效率

**Before**:

开发者手写测试时，要自己研究内存后端怎么初始化、鉴权身份如何注入、定时函数怎么触发，鉴权与错误分支常被漏掉，只能靠线上部署手动试错，一次回归验证动辄一个多小时。

**After**:

此技能直接产出可运行的 convex-test + vitest 用例，覆盖参数与返回值、鉴权与错误路径、索引和定时函数，本地内存后端即可验证，测试保持确定性，几分钟内就能拿到可信的回归结果。

| Metric | Before | After | Change |
|---|---|---|---|
| 编写首个测试文件耗时 | 90分钟 | 15分钟 | -83% |
| 鉴权/错误分支遗漏率 | 40% | 5% | -88% |

## Readme

<!-- GENERATED from convex-agents content/capabilities/test.json — do not edit by hand. -->

# Generate Convex tests

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

## 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.

## 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).


---
*Source: https://skills.yangsir.net/skill/gh-convex-test*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-convex-test/markdown*