bdd-regression-test-generator
bdd-regression-test-generator
Un agente autónomo que analiza endpoints de API REST y contratos de servicio OpenAPI/Swagger para generar:
Especificaciones BDD Gherkin (archivos
.feature) que describen todos los escenarios de camino feliz y casos límite.Scripts de prueba de regresión en TypeScript (listos para Jest + Playwright) para ejecutar contra servicios reales.
Expone dos interfaces:
Interfaz | Descripción |
CLI |
|
Servidor MCP | Servidor del Protocolo de Contexto de Modelo (MCP) expuesto a cualquier host compatible con MCP (p. ej., IBM Bob, Claude Desktop) |
Características
Analiza contratos OpenAPI 3.x y Swagger 2.0 (JSON o YAML).
Extrae todas las rutas, métodos HTTP, parámetros, cuerpos de solicitud y esquemas de respuesta.
Genera un archivo
.featurepor grupo de etiquetas de endpoint.Genera un archivo
*.spec.tspor grupo de etiquetas de endpoint con casos de prueba Jest totalmente tipados.Admite inyección de URL base personalizada en el momento de la generación.
El servidor MCP expone las herramientas
analyze_contract,generate_gherkinygenerate_tests.
Related MCP server: Swagger Testcase MCP
Instalación
npm install
npm run buildPara usar como CLI global después de compilar:
npm linkUso de la CLI
# Generate both Gherkin and Jest tests from an OpenAPI YAML spec
bdd-gen generate --input ./petstore.yaml --output ./generated --baseUrl https://api.example.com
# Generate only Gherkin feature files
bdd-gen generate --input ./petstore.json --output ./generated --only gherkin
# Generate only Jest test scripts
bdd-gen generate --input ./petstore.json --output ./generated --only jest
# Analyze a contract and print a summary (no file generation)
bdd-gen analyze --input ./petstore.yamlOpciones de la CLI
Opción | Alias | Descripción | Predeterminado |
|
| Ruta al archivo de contrato OpenAPI/Swagger | obligatorio |
|
| Directorio donde se escribirán los archivos generados |
|
|
| URL base para incrustar en los archivos de prueba generados |
|
| Generar solo | ambos | |
|
| Habilitar registro detallado |
|
Servidor MCP
Inicie el servidor MCP con:
npm run mcpEl servidor registra las siguientes herramientas:
analyze_contract
Analiza un contrato OpenAPI/Swagger desde una ruta de archivo o una cadena JSON/YAML sin procesar.
Entrada:
{ "source": "./petstore.yaml" }Salida: Un objeto JSON ContractSummary estructurado con rutas, métodos, parámetros y esquemas.
generate_gherkin
Genera contenido Gherkin .feature a partir de un contrato analizado.
Entrada:
{
"source": "./petstore.yaml",
"outputDir": "./generated"
}Salida: Lista de rutas de archivos .feature escritos.
generate_tests
Genera scripts de prueba Jest en TypeScript a partir de un contrato analizado.
Entrada:
{
"source": "./petstore.yaml",
"outputDir": "./generated",
"baseUrl": "https://api.example.com"
}Salida: Lista de rutas de archivos .spec.ts escritos.
Estructura del Proyecto
bdd-regression-test-generator/
├── src/
│ ├── parser/
│ │ └── contract-analyzer.ts # OpenAPI/Swagger parser and extractor
│ ├── generator/
│ │ ├── gherkin-builder.ts # Gherkin .feature file builder
│ │ └── jest-builder.ts # TypeScript Jest spec builder
│ ├── mcp/
│ │ └── server.ts # MCP server exposing generation tools
│ └── cli.ts # Commander-based CLI entry point
├── tests/
│ └── generator.test.ts # Unit tests for parser and generators
├── dist/ # Compiled output (after build)
├── package.json
├── tsconfig.json
└── README.mdEjecución de Pruebas
npm testCon cobertura:
npm run test:coverageEjemplo: Gherkin Generado
Feature: Pets
Background:
Given the API base URL is "https://api.example.com"
Scenario: GET /pets - list all pets - success
Given I have valid authentication credentials
When I send a GET request to "/pets"
Then the response status code should be 200
And the response body should match the "PetList" schema
Scenario: GET /pets - list all pets - unauthorized
Given I have invalid or missing authentication credentials
When I send a GET request to "/pets"
Then the response status code should be 401Ejemplo: Prueba Jest Generada
import axios from 'axios';
const BASE_URL = 'https://api.example.com';
describe('Pets', () => {
describe('GET /pets', () => {
it('should return 200 for a valid request', async () => {
const response = await axios.get(`${BASE_URL}/pets`);
expect(response.status).toBe(200);
});
});
});Licencia
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for AI access to Swagger by SmartBear.
MCP server for AI access to SmartBear tools, including BugSnag, Reflect, Swagger, PactFlow, QTM4J.
- TypeshipOAuthdev.typeship
Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.
327 dev tools via REST API and MCP. Generate Dockerfiles, schemas, K8s, APIs, and more.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server for the comprehensive analysis of Swagger 2.0 and OpenAPI 3.x contracts. It allows users to extract detailed information about endpoints, request/response schemas, parameters, and security configurations from API documentation.-
- AlicenseAqualityFmaintenanceMCP server for API test case generation from Swagger/OpenAPI specs. Parses Swagger 2.0 and OpenAPI 3.x, generates test cases across 8 categories (positive, negative, boundary, auth, security, idempotency, pagination, business logic), and exports to Postman, TestRail, Allure, k6, pytest, Gherkin, and CSV. Supports internal corporate APIs with auth headers. Auto-saves export files to your working di1010 npm2MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that automates Playwright-based UI and API testing, supporting test case generation from requirements or API specs, and execution with detailed reports.4 npm1MIT
- AlicenseNot gradedqualityCmaintenanceHigh-performance MCP server for OpenAPI specifications that parses specs, diffs versions, tracks dependencies, and generates code (TypeScript, Rust, Python).3 npm2MIT