SM

studentofjs/mcp-frontend-testing

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

26 stars 8 forks 质量 45 趋势 11MIT

模型上下文协议的前端测试工具

概览

该MCP服务器提供前端测试工具,包括: - : 分析JavaScript/TypeScript代码以确定合适的测试策略。- : 生成Jest和Cypress的单元测试和组件测试。- : 使用Jest和Cypress执行测试并返回结果。- : 提供专门用于测试React组件的工具。 1. \git clone MCP-前端测试\ 2.\CD MCP-前端测试\ 3.\npm 安装\ - : 分析代码并返回分析结果。- : - \code\(字符串,必需):分析的源代码。- \language\(枚举,可选):代码语言(\javascript\ | \typescript\ | \jsx\ | \tsx\,默认:\javascript)。- : 基于源代码和框架生成测试代码。- : - \code\(字符串,必需):用于生成测试的源代码。- \framework\(枚举,必需):测试框架(\jest\ | \cypress)。- \type\(枚举,必填):测试类型(\unit\ | \component\ | \e2e)。

概述(AI 翻译)

描述

该MCP服务器提供前端测试工具,包括:

  • 代码分析:分析JavaScript/TypeScript代码以确定合适的测试策略。
  • 测试生成:生成Jest和Cypress的单元和组件测试。
  • 测试运行:使用Jest和Cypress执行测试并返回结果。
  • 组件测试:提供专门用于测试React组件的工具。

开始

安装

  1. 克隆仓库: `git clone mcp-frontend-testing`
  2. 导航到项目目录: `cd mcp-frontend-testing`
  3. 安装依赖: `npm install`

运行服务器

HTTP 传输

``'bash(砰)

构建服务器

NPM 运行构建

用HTTP传输启动服务器

NPM 运行开始:http ``'

市交通

``'bash

构建服务器

NPM 运行构建

用Stdio运输启动服务器

NPM run start:stdio ``'

用途

工具

  • analyzeCode:分析代码并返回分析结果。
  • 参数:
  • `code`(字符串,必需):用于分析的源代码。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Frontend Testing Server

Description

This MCP server provides tools for frontend testing, including:

  • Code Analysis: Analyzes JavaScript/TypeScript code to determine appropriate testing strategies.
  • Test Generation: Generates unit and component tests for Jest and Cypress.
  • Test Running: Executes tests using Jest and Cypress and returns results.
  • Component Testing: Provides a tool specifically for testing React components.

Getting Started

Installation

  1. Clone the repository: `git clone mcp-frontend-testing`
  2. Navigate to the project directory: `cd mcp-frontend-testing`
  3. Install dependencies: `npm install`

Running the Server

HTTP Transport

```bash

Build the server

npm run build

Start the server with HTTP transport

npm run start:http ```

Stdio Transport

```bash

Build the server

npm run build

Start the server with Stdio transport

npm run start:stdio ```

Usage

Tools

  • analyzeCode: Analyzes code and returns analysis results.
    • Parameters:
      • `code` (string, required): The source code to analyze.
      • `language` (enum, optional): Language of the code (`javascript` | `typescript` | `jsx` | `tsx`, default: `javascript`).
  • generateTest: Generates test code based on source code and framework.
    • Parameters:
      • `code` (string, required): The source code to generate tests for.
      • `framework` (enum, required): Testing framework (`jest` | `cypress`).
      • `type` (enum, required): Type of test (`unit` | `component` | `e2e`).
      • `language` (enum, optional): Language of the code (`javascript` | `typescript` | `jsx` | `tsx`, default: `javascript`).
      • `description` (string, optional): Description of the test case.
  • runTest: Runs tests and returns results.
    • Parameters:
      • `sourceCode` (string, required): The source code being tested.
      • `testCode` (string, required): The test code to execute.
      • `framework` (enum, required): Testing framework (`jest` | `cypress`).
      • `type` (enum, required): Type of test (`unit` | `component` | `e2e`).
      • `config` (record, optional): Configuration object for test execution.
  • testReactComponent: Runs component tests specifically for React components.
    • Parameters:
      • `componentCode` (string, required): The source code of the React component.
      • `testCode` (string, optional): Test code for the component (auto-generated if not provided).
      • `framework` (enum, optional): Testing framework (`jest` | `cypress`, default: `jest`).
      • `props` (record, optional): Props to pass to the component during testing.
在 GitHub 查看完整 README

安装

docker run -p 3000:3000 mcp-frontend-testing
新手?先看 mcpskill.org 教程 →