AGENT SKILL

testing

Testing workflow and quality standards for writing and running tests. Use when: (1) Writing new tests, (2) Adding a new feature that needs tests, (3) Modifying logic that has existing tests, (4) Before claiming a task is complete.

License 许可
Apache-2.0
最近更新
2026-07-14
Stars
★ 0
Forks
0

01 前言 Front Matter

name
testing
description
Testing workflow and quality standards for writing and running tests. Use when: (1) Writing new tests, (2) Adding a new feature that needs tests, (3) Modifying logic that has existing tests, (4) Before claiming a task is complete.

03 SKILL.md 正文

Testing Skill

Standards and workflow for writing and running tests. Every feature must be tested.

Announce at start: "I'm using testing skill to ensure proper test coverage."

Trigger Conditions

  • Writing new tests for a feature or bug fix
  • Adding a new feature (must include tests)
  • Modifying logic that has existing tests (must update them)
  • Before claiming work is complete
  • Before committing code

Framework

Vitest 4 — configured in vitest.config.ts.

Test Structure

tests/
├── unit/          # Individual functions, utilities, components
├── integration/   # IPC, database, service interactions
├── regression/    # Regression test cases
└── e2e/           # End-to-end tests (Playwright, playwright.config.ts)

Two Test Environments

Environment When File naming
node (default) Main process, utilities, services *.test.ts
jsdom DOM/browser-dependent code *.dom.test.ts

Workflow

Step 1: Identify What to Test

Before writing tests, list the riskiest scenarios first:

  • What happens when the dependency returns undefined / throws?
  • What happens at boundaries (empty list, max retries, past timestamp)?
  • What is most likely to break in production?

Step 2: Write Tests

Follow these quality rules:

1. Describe behavior, not code structure

// Wrong — describes implementation
it('should call repo.getConversation', ...)

// Correct — describes behavior
it('should return cached task without hitting repo on second call', ...)
it('should reject with error when conversation does not exist', ...)

2. Every describe block must cover at least one failure path

Happy-path-only tests leave the most dangerous code untested.

3. One behavior per test

Keep each it() focused. More than 3 expect() calls in one test is a signal it is testing too much at once.

4. Self-check

After writing a test, mentally delete the core logic it targets. If the test would still pass, rewrite it — it is not guarding anything.

5. Start from risk, not from coverage gaps

List scenarios most likely to produce bugs. Write those first. Coverage is the outcome, not the starting point.

Step 3: Run Tests

bun run test              # Run all tests (REQUIRED before every commit)
bun run test:coverage     # Check coverage (before opening a PR)

Step 4: Verify Coverage

Coverage target: ≥ 80% for all source files matched by vitest.config.ts → coverage.include (currently src/**/*.{ts,tsx} plus a few scripts).

New source files are automatically included in coverage — no manual config changes needed. If a new file is accidentally excluded by a rule in coverage.exclude, remove it from the exclude list.

Step 5: Update Existing Tests

When modifying logic, check if existing tests need updating:

bun run test -- --reporter=verbose   # See which tests pass/fail with names

If a test fails because the behavior changed intentionally, update the test. If it fails unexpectedly, investigate.

Edge Case Checklist

When testing a module, verify:

  • [ ] null / undefined inputs handled
  • [ ] Empty arrays/objects handled
  • [ ] Error thrown by dependencies handled
  • [ ] Boundary values (0, -1, max, empty string)
  • [ ] Async operations (timeout, rejection, cancellation)

Quick Checklist

Before submitting code:

  • [ ] New features have corresponding test cases
  • [ ] Modified logic has updated tests
  • [ ] bun run test passes
  • [ ] Tests describe behavior, not implementation
  • [ ] At least one failure path per describe block
  • [ ] New source files are not accidentally excluded by coverage.exclude
  • [ ] bun run test:coverage meets ≥ 80% target

Common Mistakes

Mistake Correct
Testing implementation details Test observable behavior
Only testing happy path Must include at least one failure path
5+ expects in one it() Split into separate tests
Skipping tests for "simple" code Simple code breaks too — test the risky parts
Writing tests after saying "done" Tests are part of "done", not an afterthought

04 同仓库更多 Skills

finewood2008
finewood2008/centaurai-team

团队周报

Use when generating structured weekly team reports from git commits, task boards, and meeting notes. Auto-aggregates work done, work planned, blockers, and metrics. Chinese output by default. Trigger on: weekly report, 周报, sprint review, 本周总结, team update, status report.

★ 0
finewood2008
finewood2008/centaurai-team

中英互译

Use when translating content between Chinese and English for business, technical, or marketing purposes. Handles docs, emails, UI strings, marketing copy, and technical documentation with domain-aware terminology. Trigger on: 翻译, translate, 中译英, 英译中, i18n, localization, English version, 中文版.

★ 0
finewood2008
finewood2008/centaurai-team

社媒规划

Use when planning, drafting, or scheduling social media content for WeChat Official Account, Twitter/X, and Xiaohongshu. Generates content calendars with platform-adapted copy, publishing schedules, and performance tracking. Trigger on: social media, 公众号, 推文, content calendar, 社媒, 发布计划.

★ 0
finewood2008
finewood2008/centaurai-team

项目任务看板

Use when managing team projects, tasks, or sprint tracking with a lightweight markdown kanban board. Create, update, assign, and track tasks across team members without external tools. Trigger on: task board, kanban, sprint planning, assign task, task status, project progress.

★ 0
finewood2008
finewood2008/centaurai-team

新人入职

Use when onboarding a new team member to the company, project, or development environment. Covers environment setup, account provisioning, access permissions, first-day tasks, and knowledge base orientation. Trigger on: onboarding, 入职, new employee, 新人, setup workstation, 环境配置, first day.

★ 0
finewood2008
finewood2008/centaurai-team

会议纪要

Use when recording, structuring, or extracting action items from team meetings. Creates standardized meeting minutes with decisions, action items with owners and deadlines, and follow-up tracking. Trigger on: meeting notes, 会议纪要, meeting minutes, 开会记录, standup notes, decision log, 会议记录.

★ 0