Agent Skillsstella/stella › conventions-testing

conventions-testing

GitHub

定义测试编写与审查规范,涵盖测试范围、不变量优先策略及结构规则。指导使用 Bun 和 Playwright,强调通过类型、Schema 等构建持久化防护,避免浅层测试,确保代码质量与安全边界。

.ai/local-skills/conventions-testing/SKILL.md stella/stella

Trigger Scenarios

编写单元测试或集成测试 审查现有测试代码 设计属性测试或模糊测试

Install

npx skills add stella/stella --skill conventions-testing -g -y
More Options

Non-standard path

npx skills add https://github.com/stella/stella/tree/main/.ai/local-skills/conventions-testing -g -y

Use without installing

npx skills use stella/stella@conventions-testing

指定 Agent (Claude Code)

npx skills add stella/stella --skill conventions-testing -a claude-code -g -y

安装 repo 全部 skill

npx skills add stella/stella --all -g -y

预览 repo 内 skill

npx skills add stella/stella --list

SKILL.md

Frontmatter
{
    "name": "conventions-testing",
    "description": "Apply when writing or reviewing tests."
}

Testing Conventions

Apply when writing or reviewing tests.

What to test

Test when code has: parsing/transformation logic, security boundaries, business rules with arithmetic, state machines, non-obvious edge cases, or CRUD paths with auth, tenancy, validation, serialization, uploads/downloads, or other side effects. Skip: shallow CRUD handlers with no meaningful branching, library wrappers, layout components, constants.

Prefer invariants over examples

When the input space is large (parsers, document transforms, normalization, sorting/filtering, security boundaries, Unicode-heavy logic), start by asking what must always be true, then encode that as a property test, fuzzy test, or adversarial regression test. Reach for ordinary example tests when they communicate a business rule more clearly than a property.

Good property/fuzz targets in Stella: DOCX/OOXML roundtrips, template/block-directive parsing, filename and header sanitization, search/filter/sort helpers, tenant-scope enforcement, and error normalization.

Structure

Colocate foo.test.ts next to foo.ts. For frontend, default to extracting logic into foo.logic.ts and test that in Bun. Use Playwright for browser-only behavior: auth redirects, route guards, uploads/downloads, keyboard/focus, drag/drop, and viewer/editor flows. Structural invariant tests (auth enforcement, branded types) live in apps/api/src/tests/security/.

Rules

  • Use bun:test for unit, invariant, and integration tests; use Playwright for browser behavior. Do not add another test runner without a clear gap Bun and Playwright cannot cover.
  • Describe by behaviour, not by function name
  • Avoid hidden shared mutable state. Prefer per-test setup; use beforeEach only for deterministic reset, and use expensive shared fixtures only when explicit and isolated
  • Prefer plain fakes over mocking libraries for simple cases; use mocks when simulating failure modes, testing varied edge-case inputs, or isolating external services
  • Test tenant isolation and ownership-source rules at the highest meaningful layer, not only as pure helper tests
  • Every bug fix needs a durable guard, but not necessarily an example test: prefer types, derivation, schemas, lint rules, or broader invariants when they eliminate the bug class
  • Guard the invariant, not the accident. Do not memorialize a one-off typo, stale literal, or incidental implementation detail in a dedicated test when structural coupling makes that failure impossible
  • Avoid "tests for tests' sake": don't add shallow examples just to increase coverage if a stronger invariant test would cover the same surface with more signal
  • Run tests through the owning package script so preloads and setup survive: bun run test -- --bail -t "<name>". Do not call a raw runner from the worktree root when the package script supplies configuration.
  • Verify a new regression test fails against the known-bad behavior before trusting it. A test that never reaches the fault, or matches zero tests, is not a guard.
  • For systemic bugs, test the class: fixed points for replay, matrices for tenant isolation, properties for parsers/normalizers, state-machine transitions for lifecycle code, and round trips for serialization.
  • Keep time, randomness, network, filesystem, and database ownership explicit in tests. Pin or inject them rather than relying on ambient machine state.

Version History

  • dd81665 Current 2026-08-16 07:09

    优化测试指南,强调优先使用不变量防护而非仅记录示例,并格式化请求上下文助手相关文档。

  • 85792bd 2026-07-24 16:12

Same Skill Collection

.agents/skills/click-around/SKILL.md
.agents/skills/conventions-ai/SKILL.md
.agents/skills/conventions-db/SKILL.md
.agents/skills/conventions-i18n/SKILL.md
.agents/skills/conventions-ingestion/SKILL.md
.agents/skills/conventions-perf/SKILL.md
.agents/skills/conventions-scale/SKILL.md
.agents/skills/conventions-security/SKILL.md
.agents/skills/conventions-use-effect/SKILL.md
.agents/skills/conventions-ux/SKILL.md
.agents/skills/dev/SKILL.md
.agents/skills/finish-pr/SKILL.md
.agents/skills/new-handler/SKILL.md
.agents/skills/open-pr/SKILL.md
.agents/skills/plan/SKILL.md
.agents/skills/product-deep-think/SKILL.md
.agents/skills/product-think/SKILL.md
.agents/skills/rabbit-round/SKILL.md
.agents/skills/regression-hunt/SKILL.md
.agents/skills/security-audit/SKILL.md
.agents/skills/update-deps/SKILL.md
.ai/local-skills/click-around/SKILL.md
.ai/local-skills/conventions-ai/SKILL.md
.ai/local-skills/conventions-db/SKILL.md
.ai/local-skills/conventions-i18n/SKILL.md
.ai/local-skills/conventions-ingestion/SKILL.md
.ai/local-skills/conventions-perf/SKILL.md
.ai/local-skills/conventions-scale/SKILL.md
.ai/local-skills/conventions-security/SKILL.md
.ai/local-skills/conventions-use-effect/SKILL.md
.ai/local-skills/conventions-ux/SKILL.md
.ai/local-skills/dev/SKILL.md
.ai/local-skills/new-handler/SKILL.md
.ai/local-skills/open-pr/SKILL.md
.ai/local-skills/plan/SKILL.md
.ai/local-skills/product-deep-think/SKILL.md
.ai/local-skills/rabbit-round/SKILL.md
.ai/local-skills/security-audit/SKILL.md
.ai/local-skills/update-deps/SKILL.md
packages/cli/skills/stella-cli/SKILL.md
packages/skills/blueprints/answer-from-sources/SKILL.md
packages/skills/blueprints/blank/SKILL.md
packages/skills/blueprints/check-against-rules/SKILL.md
packages/skills/blueprints/intake-to-draft/SKILL.md
.agents/skills/conventions-testing/SKILL.md

Metadata

Files
0
Version
dd81665
Hash
9fe8a320
Indexed
2026-07-24 16:12

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 19:43
浙ICP备14020137号-1 $mapa de visitantes$