AgentSkillsCN

tap-test-gen

为指定的服务或路由生成新的后端测试文件,采用 `tap` 测试框架。当您需要编写新的后端测试用例时,可使用此技能。

SKILL.md
--- frontmatter
name: tap-test-gen
description: Generates a new backend test file using `tap` for a given service or route. Use this when you need to create a new backend test.

Tap Test Generator

This skill automates the creation of backend tests using the tap framework, ensuring consistency with existing project patterns.

Usage

To generate a test, run the generate_test.cjs script with the relative path to the source file you want to test.

bash
node .gemini/skills/tap-test-gen/scripts/generate_test.cjs <SourceFilePath>

Examples:

  • node .gemini/skills/tap-test-gen/scripts/generate_test.cjs services/choreService.ts
  • node .gemini/skills/tap-test-gen/scripts/generate_test.cjs routes/analytics.ts

What it does

  1. Determines the test type (Service vs. Route) based on the file path.
  2. Creates a test file in server/test/<type>/<Filename>.test.ts.
  3. Populates the file with the appropriate boilerplate:
    • Services: Imports prisma and sets up a basic test block with teardown.
    • Routes: Imports build from app.js and sets up app.inject testing structure.
    • Others: Sets up a generic tap test block.