Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

full-test-coverage完整的测试覆盖率

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

259

周安装

11

GitHub Stars

1

下载量

91
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:full-test-coverage(完整的测试覆盖率)
来源仓库:https://github.com/tech-stack-dev/full-test-coverage
仓库路径:skills/full-test-coverage
安装命令:
npx skills add https://github.com/tech-stack-dev/full-test-coverage --skill full-test-coverage
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/tech-stack-dev/full-test-coverage --skill full-test-coverage

简介

full-test-coverage 用于辅助测试设计、自动化测试、用例整理和回归验证,适合让 Agent 编写单元测试或端到端测试。

  • 适用于需要提升测试覆盖率或验证功能稳定性的场景。
  • 使用时需确认项目测试框架、运行命令和夹具数据,避免误改真实逻辑。
  • 涉及浏览器或外部服务时,应区分本地模拟与生产环境。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Full Test Coverage — Test Generation

Generate the right tests for every layer of the testing pyramid: unit, integration, API, and E2E. The skill analyzes the code, selects the correct layers, and implements each one following strict guidelines.

Testing Pyramid

        ╔═══════════════════════╗
        ║    E2E Tests          ║  Playwright browser · user journeys
        ╠═══════════════════════╣
        ║  API Tests            ║  Playwright HTTP · HTTP contracts
        ╠═══════════════════════╣
        ║Integration            ║  Vitest + Prisma · every branch with real DB
        ╠═══════════════════════╣
        ║  Unit Tests           ║  Vitest · isolated logic, no I/O
        ╚═══════════════════════╝

Layer Responsibility Matrix

Each concern is owned by exactly one layer. Do not duplicate responsibilities.

ConcernUnitIntegrationAPIE2E
Zod field exhaustive validationOwner1–2 wiring checks1 per endpointNo
Service method branchesOwner (mocked deps)Owner (real DB)NoNo
Pure utility functionsOwnerNoNoNo
Mock call argument verificationOwnerNoNoNo
HTTP contract (status codes, body)NoNoOwnerNo
Write verification (POST→GET, DELETE→404)NoNoOwnerNo
Authorization enforcement (401, 403)NoOwnerOwnerNo
External service calls (mocked)Owner (vi.mock)Owner (Wiremock)NoNo
DB persistence verificationNoOwnerNoNo
Complete user journey through UINoNoNoOwner
Navigation and routingNoNoNoOwner

Step 1: Analyze the Code

Before selecting layers or writing any tests, read the target code.

First, discover the full scope. Use the Explore agent (subagent_type=Explore, thoroughness="very thorough") with the following prompt:

"Find all source files related to [domain keyword] in this repository. Search comprehensively: - Files and directories whose name contains the keyword in any case variant (kebab-case, camelCase, snake_case) - Files anywhere in the repo whose content references the domain — route registrations, class names, import paths - HTTP route handlers, service classes, Zod schemas/DTOs, utility modules, serverless/Lambda handlers, shared infrastructure - Follow import chains from every file found to include referenced schemas, services, clients, and error definitions Do not restrict the search to src/ or any assumed directory. Return a complete list of files with a one-line description of each."

Use the returned file list as the scope for all subsequent steps.

Then read:

  • Zod schemas / DTOs
  • Service classes (regardless of naming prefix)
  • Route and request handlers
  • Utility and shared modules
  • DB schema (prisma/schema.prisma)
  • Error definitions
  • External service clients (if any)
  • UI components / pages (if any — look for data-testid attributes)

Build an inventory:

  • Schemas found: *list field names and rules*
  • Service methods found: *list method names and their dependencies*
  • HTTP endpoints found: *list METHOD /path*
  • Utility functions found: *list exported functions*
  • External service calls found: *list service names*
  • UI pages found: *list page URLs*

Write a one-paragraph summary: "This module has X schemas, Y service methods, Z endpoints... Recommended layers: [list]."


Step 2: Select Layers

Apply this decision tree after completing Step 1:

Does the code have Zod schemas or pure utility functions?
  YES → Unit tests required (always the baseline layer)

Does the code have service methods with branches (if/else, switch, throw)?
  YES → Unit tests (mocked) + Integration tests (real DB) required
  Why: unit tests prove logic; integration tests prove wiring with real DB.
        Together they are not redundant — they cover different failure modes.

Does the code expose HTTP endpoints?
  YES → API tests required (one spec file per endpoint)

Does the code have browser UI with data-testid attributes?
  YES → E2E tests required (one spec per feature area)

Common combinations:

  • Pure utility library → Unit only
  • Backend service, no UI → Unit + Integration + API (if endpoints exist)
  • Full-stack feature → All four layers

State explicitly which layers are selected and which are skipped with a reason: *"Skipping E2E: no browser UI found in this module."*


Step 3: Generate Tests, Layer by Layer

Work bottom-up. Generate unit tests first, then integration, then API, then E2E. Complete and self-validate each layer before moving to the next.

If Unit tests are selected:

Read references/unit-testing.md before writing any code.

Key steps:

  1. Read schemas, service, utils, errors
  2. Map every field × rule and every service branch as a case tree (write as comments first)
  3. Create schema.helper.ts and <domain>.unit-factory.ts
  4. Write schema tests (one describe per field, one it() per rule)
  5. Write service tests (all branches mocked, exact mock argument verification)
  6. Write utility tests (if applicable)
  7. Run: vitest run src/modules/<domain>/test/unit/
  8. Run self-validation checklist from the reference file

If Integration tests are selected:

Read references/integration-testing.md before writing any code.

Key steps:

  1. Read source + auth implementation + error response shape (determines assertion format)
  2. List every execution path as comments inside describe blocks
  3. Create DatabaseHelper, AuthHelper, fixtures, api-utils
  4. Write handler tests (1–2 validation wiring tests per endpoint — no exhaustive Zod rules)
  5. Write service layer tests (direct calls, real DB)
  6. Run: yarn test:integration (or equivalent)
  7. Run self-validation checklist from the reference file

If API tests are selected:

Read references/api-testing.md before writing any code.

Key steps:

  1. Read route handlers, DTOs, error definitions
  2. Verify/create response helpers for all error codes
  3. Create test-owned factory (never import backend DTOs)
  4. Create API utilities (one function per endpoint)
  5. Create cleanup utilities
  6. Write test specs: plan scenarios as comments first, then implement
  7. Run: npx playwright test --project=api
  8. Run self-validation checklist from the reference file

If E2E tests are selected:

Read references/e2e-testing.md before writing any code.

Key steps:

  1. Read PRD, page components (data-testid attributes), existing fixtures
  2. Identify user flows (one spec file per feature area)
  3. Create or update Page Object Models (locators via data-testid only)
  4. Create test data factory with counter + timestamp + random pattern
  5. Create API-based setup helper and cleanup helper
  6. Write test specs (API setup, inject auth, navigate, UI interaction, assert)
  7. Run: npx playwright test --project=chromium
  8. Run self-validation checklist from the reference file

Universal Patterns

These apply at every layer. Do not repeat in reference files.

Unique test data

let counter = 0;
function uniqueSuffix(): string {
  counter++;
  return `${counter}-${Date.now()}-${Math.floor(Math.random() * 100000)}`;
}
// Usage: `test-user-${uniqueSuffix()}@test.com`

Why: parallel test runs share a database. Non-unique data causes false failures when one test's cleanup deletes another test's records.

Arrange-Act-Assert

Every test follows this exact structure:

// Arrange — set up state
const cookie = await authenticateUser(request);
const dto = generateCreateNoteDto();

// Act — execute the behavior
const response = await executePostNoteRequest(request, dto, cookie);

// Assert — verify the result
expect201Created(response);
expect(response.data.title).toBe(dto.title);

Cleanup in afterEach

// ✓ Correct — runs even when test throws
test.afterEach(async ({ request }) => {
  for (const cookie of cookiesToCleanup) {
    await cleanupNotes(request, cookie);
    await cleanupUser(request, cookie);
  }
  cookiesToCleanup.length = 0;
});

// ✗ Wrong — skipped when test throws before reaching cleanup
test("...", async ({ request }) => {
  const cookie = await authenticateUser(request);
  // ...
  await cleanupUser(request, cookie); // This line may never run
});

No shared state between tests

  • No beforeAll for shared data
  • No shared auth sessions
  • Each test creates its own user and test entities

No static waits

// ✗ Forbidden at all layers
await new Promise(resolve => setTimeout(resolve, 1000));
await page.waitForTimeout(5000);

// ✓ Use explicit conditions instead
// API/Integration: poll with 400ms interval, 15s timeout
// E2E: locator.waitFor(), page.waitForURL(), expect(locator).toBeVisible()

No snapshot tests

.toMatchSnapshot() and .toMatchInlineSnapshot() are forbidden at all layers. Snapshots hide intent and produce opaque diffs.

No hardcoded URLs

Always use relative paths. Playwright's baseURL from config handles environment switching.


Reference File Guide

When generating tests for a layer, read the corresponding reference file first. Each file includes the full workflow, verbatim templates, and a self-validation checklist.

FileContainsKey templates
references/unit-testing.md8-step workflow, Zod test patterns, mocking rulesschema.helper.ts, unit factory, service test structure
references/integration-testing.md5-step workflow, parallel-safe cleanup, validation wiringDatabaseHelper, AuthHelper (both variants), fixture structure
references/api-testing.md8-step workflow, test-owned interfaces, write verificationauthenticateUser(), API utilities, response helpers, per-endpoint test counts
references/e2e-testing.md9-step workflow, POM rules, waiting strategycreateUserViaApi(), injectAuthCookie(), Page Object Model, 5 wait patterns

Cross-Layer Checklist

After all layers are complete, verify the pyramid is correctly shaped:

No layer duplication:

  • Unit tests cover Zod field validation exhaustively — integration/API/E2E do not
  • Integration tests have only 1–2 validation wiring tests per endpoint
  • API tests have only 1 validation test per endpoint
  • E2E tests cover user journeys and navigation — no field validation

Pyramid shape (count tests per layer):

  • Unit tests cover the most cases — exhaustive per field and per branch
  • Integration tests are fewer — only real DB wiring and auth paths
  • API tests are fewer still — one spec per endpoint
  • E2E tests are the fewest — one spec per user journey

All self-validation checklists were run:

  • Unit layer checklist ✓
  • Integration layer checklist ✓
  • API layer checklist ✓
  • E2E layer checklist ✓

Cross-Layer Examples

The same "notes" domain — showing exactly how coverage is divided, not duplicated.

Testing a title field (min 1, max 255, required)

LayerWhat to testTest count
Unitmissing, undefined, null, empty string, min boundary (1 char ✓), max boundary (255 chars ✓), 256 chars ✗, wrong type (number)8+ tests
Integrationone representative: missing title → 400 VALIDATION_ERROR (proves Zod is wired)1 test
APIone representative: missing title → 400 (verifies HTTP contract)1 test
E2Enothing — E2E tests do not test field validation0 tests

Testing a notFound service branch

LayerWhat to test
Unitmock prisma.note.findUnique to return null → verify Errors.notFound() thrown; verify downstream mocks NOT called
Integrationrequest with a real non-existent ID in DB → verify 404 response with correct NOT_FOUND code
APIGET /api/notes/:nonExistentId → verify 404 with correct error body
E2Enothing — E2E tests don't test error branches

Testing an authorization rule

LayerWhat to test
Unitmock prisma.note.findUnique to return a note with organizationId: "other-org" → verify Errors.forbidden() thrown; verify update mock NOT called
Integrationuser B requests note owned by user A's organization → verify 403 FORBIDDEN response and DB unchanged
APIuser B requests note owned by user A → verify 403 response
E2Everify user B cannot see user A's notes in the UI (data isolation test)

Completion

After all layers are generated, provide:

File inventory per layer:

LayerFiles createdRun command
Unit<domain>.schema.test.ts, <domain>.service.test.ts, schema.helper.ts, <domain>.unit-factory.tsvitest run src/modules/<domain>/test/unit/
Integration<endpoint>.test.ts (×N), <domain>.service.test.ts, database.helper.ts, auth.helper.ts, <domain>.fixture.ts, api-utilsyarn test:integration
API<method>-<endpoint>.spec.ts (×N), <domain>.factory.ts, <domain>.api-utils.ts, <domain>.cleanup.tsnpx playwright test --project=api
E2E<domain>.<feature>.spec.ts, <domain>.page.ts, <domain>.factory.ts, setup.ts, cleanup.tsnpx playwright test --project=chromium

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.9%
按下载量换算31

Claude

30.06%
按下载量换算27

Cursor

19.62%
按下载量换算18

Gemini CLI

10.45%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills