Agent Skills
› silo-code/silo
› silo-testing
silo-testing
GitHub用于在Silo仓库中编写或更新单元测试。涵盖Vitest配置、纯逻辑测试风格、通过valtio store驱动状态及边界情况覆盖,确保代码变更伴随完整测试。
触发场景
编写新的单元测试
更新现有测试用例
检查测试覆盖率
安装
npx skills add silo-code/silo --skill silo-testing -g -y
SKILL.md
Frontmatter
{
"name": "silo-testing",
"description": "Use when writing or updating unit tests in the Silo repo. Covers the co-located Vitest setup, the pure-logic (no @testing-library\/react) style and how to extract testable helpers, driving host state directly via the valtio store, and the contract-and-edges coverage expectations."
}
Testing in Silo
Every change that adds or changes behavior ships with unit tests in the same
change. Tests are part of the work, not a follow-up. Don't mark a task done
until pnpm test is green with coverage for what you added.
How testing works here:
- Vitest, co-located. Put
*.test.ts/*.test.tsxnext to the source it covers; the packagevitest.config.tspicks upsrc/**/*.{test,spec}.{ts,tsx}. Run everything withpnpm test, or one package withpnpm --filter <pkg> exec vitest run <path>. - Pure-logic style. The suite tests logic, not rendered React
(
@testing-library/reactis intentionally not a dependency). When the logic you're adding lives inside a component, extract it into a pure, exported helper and test that — e.g.view-switcher-model.ts(switcher show/segmented/ dropdown rules),markdown-preview/menu.ts(context-menu enablement), andmarkdown-preview/match.ts(file matching) were factored out of their components precisely so the rules are unit-testable. Components stay thin glue. - Host state can be driven directly: set up
store(the valtio proxy) and the relevant registries inbeforeEach, exercise the service, assert on the store — seeeditor-service.test.tsandeditor-registry.test.ts. - Cover the contract and the edges, not just the happy path: fallbacks,
no-ops/guards, disabled states, and "hidden/absent" cases (the editor
view-switching tests pin the priority tie-break, stale-
viewTypefallback, read-only Cut/Paste, and the single-view/diff/untitled hidden cases).
版本历史
- 95dfc72 当前 2026-08-27 21:33


