AgentSkillsCN

testsprite

借助 TestSprite MCP 实现自动化测试。当用户提及“testsprite”、“生成测试”、“测试计划”、“自动化测试”,或希望通过 TestSprite 运行端到端/集成测试时,可选用此功能。

SKILL.md
--- frontmatter
name: testsprite
description: Automated testing with TestSprite MCP. Use when user mentions "testsprite", "generate tests", "test plan", "automated testing", or wants to run E2E/integration tests via TestSprite.

TestSprite MCP Integration

TestSprite is an AI-powered test generation and execution tool. It uses MCP (Model Context Protocol) to integrate with the agent.

When to Use This Skill

  • User asks to generate tests automatically
  • User mentions "testsprite" or "test plan"
  • User wants to create a PRD from code
  • User wants to run automated E2E tests

Prerequisites

Before using any TestSprite tool, you MUST:

  1. Identify Project Path: Absolute path to project root
  2. Identify Local Port: Check vite.config.ts, package.json, or framework defaults
  3. Identify Project Type: frontend (React, Vue, Next.js) or backend (Express, NestJS, API)
  4. Identify Test Scope: codebase (full) or diff (staged changes only)

Workflow

code
┌─────────────────────────────────────────────────────────────┐
│  1. BOOTSTRAP (Required First)                              │
│     testsprite_bootstrap                                    │
│     → Sets up TestSprite for the project                    │
└─────────────────────────┬───────────────────────────────────┘
                          │
┌─────────────────────────▼───────────────────────────────────┐
│  2. ANALYSIS (Optional but Recommended)                     │
│     testsprite_generate_code_summary                        │
│     → Analyzes and summarizes the codebase                  │
│                                                             │
│     testsprite_generate_standardized_prd                    │
│     → Generates PRD from code (if no PRD exists)            │
└─────────────────────────┬───────────────────────────────────┘
                          │
┌─────────────────────────▼───────────────────────────────────┐
│  3. PLAN GENERATION                                         │
│     testsprite_generate_frontend_test_plan                  │
│     → For frontend projects                                 │
│                                                             │
│     testsprite_generate_backend_test_plan                   │
│     → For backend projects                                  │
└─────────────────────────┬───────────────────────────────────┘
                          │
┌─────────────────────────▼───────────────────────────────────┐
│  4. EXECUTION                                               │
│     testsprite_generate_code_and_execute                    │
│     → Generates test code, runs tests, saves report         │
│                                                             │
│     testsprite_rerun_tests                                  │
│     → Re-runs tests manually when needed                    │
└─────────────────────────────────────────────────────────────┘

Tool Reference

1. testsprite_bootstrap

Purpose: Initialize TestSprite for a project. MUST be called first.

ParameterTypeRequiredDescription
projectPathstringAbsolute path to project root
localPortnumberDev server port (Vite: 5173, Next: 3000, etc.)
typestringfrontend or backend
testScopestringcodebase (all) or diff (staged changes)
pathnamestringSpecific page path (e.g., /dashboard)

Port Detection Heuristics:

  • Vite/React: 5173 (default), check vite.config.ts for custom port
  • Next.js: 3000 (default)
  • Express: Check server.ts or .env for PORT
  • Storybook: 6006

2. testsprite_generate_code_summary

Purpose: Analyze repository and create codebase summary.

ParameterTypeRequiredDescription
projectRootPathstringAbsolute path to project root

Use When: Starting with an unfamiliar codebase or before generating tests.


3. testsprite_generate_standardized_prd

Purpose: Generate a structured PRD from the codebase.

ParameterTypeRequiredDescription
projectPathstringAbsolute path to project root

Use When: No PRD exists or need to document current functionality.


4. testsprite_generate_frontend_test_plan

Purpose: Generate test plan for frontend applications.

ParameterTypeRequiredDefaultDescription
projectPathstring-Absolute path to project root
needLoginbooleantrueInclude login flow in tests

Use When: Testing React, Vue, Next.js, or any frontend app.


5. testsprite_generate_backend_test_plan

Purpose: Generate test plan for backend/API applications.

ParameterTypeRequiredDescription
projectPathstringAbsolute path to project root

Use When: Testing Express, NestJS, or API endpoints.


6. testsprite_generate_code_and_execute

Purpose: Generate test code, execute tests, and save markdown report.

ParameterTypeRequiredDefaultDescription
projectPathstring-Absolute path to project root
projectNamestring-Name of root directory
testIdsstring[][]Specific test IDs (empty = all tests)
additionalInstructionstring""Extra instructions for test generation

Use When: Ready to generate and run actual tests.


7. testsprite_rerun_tests

Purpose: Re-run previously generated tests.

ParameterTypeRequiredDescription
projectPathstringAbsolute path to project root

Use When: Tests were modified or need to verify fixes.


Quick Start Examples

Frontend Project (Vite/React)

code
1. Bootstrap:
   - projectPath: "c:/Users/user/my-app"
   - localPort: 5173
   - type: "frontend"
   - testScope: "codebase"

2. Generate Test Plan:
   - projectPath: "c:/Users/user/my-app"
   - needLogin: true

3. Execute Tests:
   - projectPath: "c:/Users/user/my-app"
   - projectName: "my-app"
   - testIds: []
   - additionalInstruction: ""

Backend Project (Express)

code
1. Bootstrap:
   - projectPath: "c:/Users/user/api-server"
   - localPort: 3001
   - type: "backend"
   - testScope: "codebase"

2. Generate Test Plan:
   - projectPath: "c:/Users/user/api-server"

3. Execute Tests:
   - projectPath: "c:/Users/user/api-server"
   - projectName: "api-server"
   - testIds: []
   - additionalInstruction: "Focus on authentication endpoints"

Checklist

Use this checklist when running TestSprite:

markdown
- [ ] Identified project path
- [ ] Identified dev server port
- [ ] Identified project type (frontend/backend)
- [ ] Dev server is running (or will be started)
- [ ] Bootstrapped TestSprite
- [ ] Generated test plan
- [ ] Executed tests
- [ ] Reviewed test report

Troubleshooting

IssueSolution
Bootstrap failsCheck if project path exists and is accessible
Port not foundLook for PORT in .env or config files
Tests fail to startEnsure dev server is running on specified port
Login tests skipSet needLogin: true in frontend test plan