Major improvements based on comprehensive test suite review: Test Fixes: - Fix all 78 failing tests across logger, MSW, and validator tests - Fix console spy management in logger tests with proper DEBUG env handling - Fix MSW test environment restoration in session-management.test.ts - Fix workflow validator tests by adding proper node connections - Fix mock setup issues in edge case tests Test Organization: - Split large config-validator.test.ts (1,075 lines) into 4 focused files - Rename 63+ tests to follow "should X when Y" naming convention - Add comprehensive edge case test files for all major validators - Create tests/README.md with testing guidelines and best practices New Features: - Add ConfigValidator.validateBatch() method for bulk validation - Add edge case coverage for null/undefined, boundaries, invalid data - Add CI-aware performance test timeouts - Add JSDoc comments to test utilities and factories - Add workflow duplicate node name validation tests Results: - All tests passing: 1,356 passed, 19 skipped - Test coverage: 85.34% statements, 85.3% branches - From 78 failures to 0 failures 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
MCP Protocol Integration Tests
This directory contains comprehensive integration tests for the Model Context Protocol (MCP) implementation in n8n-mcp.
Test Structure
Core Tests
- basic-connection.test.ts - Tests basic MCP server functionality and tool execution
- protocol-compliance.test.ts - Tests JSON-RPC 2.0 compliance and protocol specifications
- tool-invocation.test.ts - Tests all MCP tool categories and their invocation
- session-management.test.ts - Tests session lifecycle, multiple sessions, and recovery
- error-handling.test.ts - Tests error handling, edge cases, and invalid inputs
- performance.test.ts - Performance benchmarks and stress tests
Helper Files
- test-helpers.ts - TestableN8NMCPServer wrapper for testing with custom transports
Running Tests
# Run all MCP protocol tests
npm test -- tests/integration/mcp-protocol/
# Run specific test file
npm test -- tests/integration/mcp-protocol/basic-connection.test.ts
# Run with coverage
npm test -- tests/integration/mcp-protocol/ --coverage
Test Coverage
These tests ensure:
- ✅ JSON-RPC 2.0 protocol compliance
- ✅ Proper request/response handling
- ✅ All tool categories are tested
- ✅ Error handling and edge cases
- ✅ Session management and lifecycle
- ✅ Performance and scalability
Known Issues
- The InMemoryTransport from MCP SDK has some limitations with connection lifecycle
- Tests use the actual database, so they require
data/nodes.dbto exist - Some tests are currently skipped due to transport issues (being worked on)
Future Improvements
- Mock the database for true unit testing
- Add WebSocket transport tests
- Add authentication/authorization tests
- Add rate limiting tests
- Add more performance benchmarks