Skip to main content
Glama
felipeassis10

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

bdd-gen generate --input <spec> --output <dir>

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 .feature por grupo de etiquetas de endpoint.

  • Genera un archivo *.spec.ts por 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_gherkin y generate_tests.


Related MCP server: Swagger Testcase MCP

Instalación

npm install
npm run build

Para usar como CLI global después de compilar:

npm link

Uso 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.yaml

Opciones de la CLI

Opción

Alias

Descripción

Predeterminado

--input <path>

-i

Ruta al archivo de contrato OpenAPI/Swagger

obligatorio

--output <dir>

-o

Directorio donde se escribirán los archivos generados

./generated

--baseUrl <url>

-b

URL base para incrustar en los archivos de prueba generados

http://localhost:3000

--only <type>

Generar solo gherkin o jest (omitir para ambos)

ambos

--verbose

-v

Habilitar registro detallado

false


Servidor MCP

Inicie el servidor MCP con:

npm run mcp

El 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.md

Ejecución de Pruebas

npm test

Con cobertura:

npm run test:coverage

Ejemplo: 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 401

Ejemplo: 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

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    An 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.
    -
  • A
    license
    A
    quality
    F
    maintenance
    MCP 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 di
    10
    10 npm
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    High-performance MCP server for OpenAPI specifications that parses specs, diffs versions, tracks dependencies, and generates code (TypeScript, Rust, Python).
    3 npm
    2
    MIT