UNPKG

backend-mcp

Version:

Generador automático de backends con Node.js, Express, Prisma y módulos configurables. Servidor MCP compatible con npx para agentes IA. Soporta PostgreSQL, MySQL, MongoDB y SQLite.

322 lines (297 loc) 8.26 kB
# modules/testing/manifest.yaml module: name: "testing" version: "1.0.0" description: "Sistema completo de testing con Jest, Supertest y configuraciones para unit, integration y e2e tests" category: "testing" triggers: - condition: "needs_testing" value: true - condition: "wants_test_automation" value: true - condition: "test_coverage" value: true - condition: "quality_assurance" value: true - condition: "ci_testing" value: true entry_points: unit_tests: "templates/unit-test.ts.hbs" integration_tests: "templates/integration-test.ts.hbs" e2e_tests: "templates/e2e-test.ts.hbs" test_config: "templates/jest.config.js.hbs" test_setup: "templates/test-setup.ts.hbs" dependencies: required: [] optional: - "database" - "auth" - "email" - "websockets" - "cache" - "logging" environment_variables: required: - NODE_ENV optional: - TEST_DATABASE_URL - TEST_REDIS_URL - TEST_JWT_SECRET - TEST_EMAIL_PROVIDER - COVERAGE_THRESHOLD - TEST_TIMEOUT features: - "unit-testing" - "integration-testing" - "e2e-testing" - "test-coverage" - "test-mocking" - "test-fixtures" - "test-database" - "test-utilities" - "performance-testing" - "load-testing" - "snapshot-testing" - "visual-regression-testing" test_types: - name: "unit" description: "Unit tests for individual functions and classes" pattern: "**/*.test.ts" timeout: 5000 - name: "integration" description: "Integration tests for API endpoints and services" pattern: "**/*.integration.test.ts" timeout: 10000 - name: "e2e" description: "End-to-end tests for complete user flows" pattern: "**/*.e2e.test.ts" timeout: 30000 - name: "performance" description: "Performance and load testing" pattern: "**/*.perf.test.ts" timeout: 60000 test_frameworks: - name: "jest" description: "Primary testing framework" features: ["mocking", "coverage", "snapshots"] - name: "supertest" description: "HTTP assertion library" features: ["api-testing", "request-mocking"] - name: "playwright" description: "E2E testing framework" features: ["browser-automation", "visual-testing"] generated_files: - "jest.config.js" - "jest.unit.config.js" - "jest.integration.config.js" - "jest.e2e.config.js" - "tests/setup.ts" - "tests/teardown.ts" - "tests/helpers/test-utils.ts" - "tests/helpers/db-helper.ts" - "tests/helpers/auth-helper.ts" - "tests/fixtures/users.json" - "tests/fixtures/products.json" - "tests/mocks/email.mock.ts" - "tests/mocks/redis.mock.ts" - "tests/unit/example.test.ts" - "tests/integration/api.test.ts" - "tests/e2e/user-flow.test.ts" - "playwright.config.ts" - ".github/workflows/test.yml" integration: database_integration: - "test-database-setup" - "transaction-rollback" - "seed-data-management" - "migration-testing" auth_integration: - "jwt-token-mocking" - "user-authentication-testing" - "permission-testing" api_integration: - "endpoint-testing" - "request-validation" - "response-assertion" - "error-handling-testing" cache_integration: - "redis-mocking" - "cache-invalidation-testing" email_integration: - "email-sending-mocking" - "template-rendering-testing" websocket_integration: - "socket-connection-testing" - "real-time-event-testing" test_utilities: - name: "test-database" description: "Isolated test database management" features: ["setup", "teardown", "seeding", "cleanup"] - name: "auth-helpers" description: "Authentication testing utilities" features: ["token-generation", "user-creation", "permission-setup"] - name: "api-helpers" description: "API testing utilities" features: ["request-builders", "response-validators", "error-matchers"] - name: "mock-factories" description: "Mock data generation" features: ["user-mocks", "product-mocks", "order-mocks"] coverage_config: threshold: global: branches: 80 functions: 80 lines: 80 statements: 80 collect_from: - "src/**/*.ts" - "!src/**/*.d.ts" - "!src/**/*.test.ts" - "!src/**/*.spec.ts" reporters: - "text" - "lcov" - "html" - "json" - "cobertura" mocking_strategies: - name: "service-mocking" description: "Mock external services and APIs" tools: ["jest.mock", "nock", "msw"] - name: "database-mocking" description: "Mock database operations" tools: ["jest-mock-extended", "prisma-mock"] - name: "email-mocking" description: "Mock email sending" tools: ["nodemailer-mock", "jest.fn"] - name: "redis-mocking" description: "Mock Redis operations" tools: ["redis-mock", "ioredis-mock"] test_data_management: fixtures: - "users.json" - "products.json" - "orders.json" - "categories.json" factories: - "user-factory.ts" - "product-factory.ts" - "order-factory.ts" seeders: - "test-seed.ts" - "integration-seed.ts" - "e2e-seed.ts" performance_testing: tools: - "artillery" - "k6" - "autocannon" metrics: - "response-time" - "throughput" - "error-rate" - "memory-usage" - "cpu-usage" scenarios: - "load-testing" - "stress-testing" - "spike-testing" - "volume-testing" usage_examples: - "Unit testing for business logic" - "Integration testing for API endpoints" - "E2E testing for user workflows" - "Performance testing for scalability" - "Database testing with transactions" - "Authentication testing with JWT" ai_instructions: | Use this module when: - User mentions "testing", "tests", "unit tests", "integration tests" - Project needs quality assurance and test coverage - CI/CD pipeline requires automated testing - Code quality and reliability are important Configuration steps: 1. Analyze existing codebase structure 2. Set up Jest configuration for different test types 3. Create test utilities and helpers 4. Generate example tests for existing code 5. Configure coverage thresholds 6. Set up test database and mocking 7. Integrate with CI/CD pipeline Always consider: - Test pyramid (unit > integration > e2e) - Coverage requirements and thresholds - Test data management and isolation - Performance testing needs - Mocking strategies for external dependencies automation: scripts: - "setup-tests.sh": "Initialize testing environment" - "run-tests.sh": "Execute all test suites" - "generate-coverage.sh": "Generate coverage reports" - "test-db-setup.sh": "Set up test database" - "performance-test.sh": "Run performance tests" testing: - "Test configuration validation" - "Mock setup verification" - "Coverage threshold validation" - "Test database connectivity" - "CI integration testing" performance: optimizations: - "Parallel test execution" - "Test result caching" - "Selective test running" - "Database transaction optimization" metrics: - "Test execution time" - "Coverage generation time" - "Memory usage during tests" - "Test reliability score" monitoring: - "Test execution metrics" - "Coverage trends" - "Test failure rates" - "Performance test results" - "Flaky test detection" security: best_practices: - "Secure test data handling" - "Test environment isolation" - "Sensitive data masking" - "Test credential management" compliance: - "Data privacy in tests" - "Test audit trails" - "Secure test execution" scaling: horizontal: - "Distributed test execution" - "Test sharding strategies" - "Parallel CI runners" vertical: - "Test performance optimization" - "Memory usage optimization" - "Test execution speed" compatibility: test_frameworks: - "Jest (primary)" - "Mocha + Chai" - "Vitest" - "Playwright" - "Cypress" ci_platforms: - "GitHub Actions" - "GitLab CI" - "Jenkins" - "CircleCI" - "Azure DevOps" databases: - "PostgreSQL" - "MySQL" - "MongoDB" - "SQLite (for testing)" node_versions: - "Node.js 16+" - "Node.js 18+" - "Node.js 20+"