Agent Skillsbiersoeckli/QuickStack › backend-testing

backend-testing

GitHub

用于创建和审查 QuickStack 后端单元测试与集成测试,涵盖 Vitest、Prisma、SQLite 及 k3s Kubernetes 环境,提供命名规范、文件结构及 Mock 策略指导。

.agents/skills/backend-testing/SKILL.md biersoeckli/QuickStack

Trigger Scenarios

编辑 src/server/ 下的后端测试文件 询问后端测试覆盖率 需要设置 Prisma 测试数据库 请求 Kubernetes 集成测试

Install

npx skills add biersoeckli/QuickStack --skill backend-testing -g -y
More Options

Non-standard path

npx skills add https://github.com/biersoeckli/QuickStack/tree/main/.agents/skills/backend-testing -g -y

Use without installing

npx skills use biersoeckli/QuickStack@backend-testing

指定 Agent (Claude Code)

npx skills add biersoeckli/QuickStack --skill backend-testing -a claude-code -g -y

安装 repo 全部 skill

npx skills add biersoeckli/QuickStack --all -g -y

预览 repo 内 skill

npx skills add biersoeckli/QuickStack --list

SKILL.md

Frontmatter
{
    "name": "backend-testing",
    "description": "Create and review QuickStack backend unit and integration tests using the project's Vitest, Prisma, SQLite, and k3s conventions. Use when editing backend test files under `src\/server\/`, `src\/shared\/`, or `src\/__tests__\/integration\/`, or when the user asks for backend test coverage, mocks, Prisma test DB setup, or Kubernetes integration tests."
}

Backend Testing

Quick Start

Use these defaults for QuickStack backend tests:

  • Name unit tests *.unit.spec.ts.
  • Name integration tests *.integration.spec.ts.
  • Keep unit tests beside the source file.
  • Put integration tests in src/__tests__/integration/ mirroring the source path.
  • Use Vitest globals without importing describe, it, expect, or vi.
  • Prefer @/... imports for app modules.

Workflow

When creating or updating backend tests:

  1. Pick the right test type: unit, Prisma/SQLite integration, or k3s integration.
  2. Place the file in the correct location and use the required filename suffix.
  3. For unit tests, mock all external dependencies and keep the suite isolated.
  4. For Prisma integration tests, use createPrismaTestContext('label').
  5. For k3s integration tests, use createK3sTestContext() and mock the Kubernetes adapter before imports.
  6. Run the smallest relevant test command first, then broaden if needed.

Unit Tests

  • Mock Prisma, Kubernetes, S3, Longhorn, filesystem, network calls, and singleton services.
  • Use vi.mock() and vi.mocked() for typed mocks.
  • Use vi.importActual() for partial mocks when needed.
  • If a module initializes from environment variables at import time, set env first and call vi.resetModules() before importing it.
  • Do not hit the real database, filesystem, or Kubernetes from unit tests.

Integration Tests

  • Use a real temporary SQLite database file instead of mocks.
  • Use createPrismaTestContext() for DB lifecycle setup and teardown.
  • Static top-level imports of services are fine with the Prisma test context.
  • Use ctx.getDataAccess().client for direct DB assertions.
  • Run mutating integration suites with --pool=forks or --no-file-parallelism when Prisma singleton state is involved.

K3s Tests

  • Use createK3sTestContext() for real Kubernetes integration coverage.
  • Mock @/server/adapter/kubernetes-api.adapter before any related imports.
  • Use ctx.getClients() for typed Kubernetes clients.
  • Use ctx.getKubeConfig() only when raw kubeconfig access is needed.
  • Expect slower startup and Docker requirements for these suites.

Reference

See REFERENCE.md for exact naming rules, folder structure, code examples, runtime caveats, and test commands.

Version History

  • 0.0.13 Current 2026-08-20 14:27

Same Skill Collection

.agents/skills/ask-matt/SKILL.md
.agents/skills/backend-services/SKILL.md
.agents/skills/code-review/SKILL.md
.agents/skills/codebase-design/SKILL.md
.agents/skills/diagnosing-bugs/SKILL.md
.agents/skills/domain-modeling/SKILL.md
.agents/skills/elysia-api-routes/SKILL.md
.agents/skills/frontend-ui-patterns/SKILL.md
.agents/skills/grilling/SKILL.md
.agents/skills/handoff/SKILL.md
.agents/skills/implement/SKILL.md
.agents/skills/improve-codebase-architecture/SKILL.md
.agents/skills/prototype/SKILL.md
.agents/skills/research/SKILL.md
.agents/skills/resolving-merge-conflicts/SKILL.md
.agents/skills/setup-matt-pocock-skills/SKILL.md
.agents/skills/tdd/SKILL.md
.agents/skills/teach/SKILL.md
.agents/skills/to-questionnaire/SKILL.md
.agents/skills/to-spec/SKILL.md
.agents/skills/to-tickets/SKILL.md
.agents/skills/triage/SKILL.md
.agents/skills/wayfinder/SKILL.md
.agents/skills/writing-for-agents/SKILL.md
.agents/skills/grill-me/SKILL.md
.agents/skills/grill-with-docs/SKILL.md

Metadata

Files
0
Version
0.0.13
Hash
7fb4fbdf
Indexed
2026-08-20 14:27

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 01:46
浙ICP备14020137号-1 $방문자$