mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 06:22:04 +00:00
* feat: Remove 9 low-value tools and consolidate n8n_health_check (v2.25.0) Telemetry-driven tool cleanup to improve API clarity: **Removed Tools (9):** - list_nodes - Use search_nodes instead - list_ai_tools - Use search_nodes with isAITool filter - list_tasks - Low usage (0.02%) - get_database_statistics - Use n8n_health_check - list_templates - Use search_templates or get_templates_for_task - get_node_as_tool_info - Documented in get_node - validate_workflow_connections - Use validate_workflow - validate_workflow_expressions - Use validate_workflow - n8n_list_available_tools - Use n8n_health_check - n8n_diagnostic - Merged into n8n_health_check **Consolidated Tool:** - n8n_health_check now supports mode='diagnostic' for detailed troubleshooting **Tool Count:** - Before: 38 tools - After: 31 tools (18% reduction) Concieved by Romuald Członkowski - www.aiadvisors.pl/en 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: cleanup stale references and update tests after tool removal - Remove handleListAvailableTools dead code from handlers-n8n-manager.ts - Update error messages to reference n8n_health_check(mode="diagnostic") instead of n8n_diagnostic - Update tool counts in diagnostic messages (14 doc tools, 31 total) - Fix error-handling.test.ts to use valid tools (search_nodes, tools_documentation) - Remove obsolete list-tools.test.ts integration tests - Remove unused ListToolsResponse type from response-types.ts - Update tools.ts QUICK REFERENCE to remove list_nodes references - Update tools-documentation.ts to remove references to removed tools - Update tool-docs files to remove stale relatedTools references - Fix tools.test.ts to not test removed tools (list_nodes, list_ai_tools, etc.) - Fix parameter-validation.test.ts to not test removed tools - Update handlers-n8n-manager.test.ts error message expectations All 399 MCP unit tests now pass. Conceived by Romuald Członkowski - www.aiadvisors.pl/en 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: update integration tests to use valid tools after v2.25.0 removal Replaced all references to removed tools in integration tests: - list_nodes -> search_nodes - get_database_statistics -> tools_documentation - list_ai_tools -> search_nodes/tools_documentation - list_tasks -> tools_documentation - get_node_as_tool_info -> removed test section Updated test files: - tests/integration/mcp-protocol/basic-connection.test.ts - tests/integration/mcp-protocol/performance.test.ts - tests/integration/mcp-protocol/session-management.test.ts - tests/integration/mcp-protocol/test-helpers.ts - tests/integration/mcp-protocol/tool-invocation.test.ts - tests/integration/telemetry/mcp-telemetry.test.ts - tests/unit/mcp/disabled-tools.test.ts - tests/unit/mcp/tools-documentation.test.ts Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: Tool consolidation v2.26.0 - reduce tools by 38% (31 → 19) Major consolidation of MCP tools using mode-based parameters for better AI agent ergonomics: Node Tools: - get_node_documentation → get_node with mode='documentation' - search_node_properties → get_node with mode='search_properties' - get_property_dependencies → removed Validation Tools: - validate_node_operation + validate_node_minimal → validate_node with mode param Template Tools: - list_node_templates → search_templates with searchMode='nodes' - search_templates_by_metadata → search_templates with searchMode='metadata' - get_templates_for_task → search_templates with searchMode='task' Workflow Getters: - n8n_get_workflow_details/structure/minimal → n8n_get_workflow with mode param Execution Tools: - n8n_list/get/delete_execution → n8n_executions with action param Test updates for all consolidated tools. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en * docs: comprehensive README update for v2.26.0 tool consolidation - Quick Start: Added hosted service (dashboard.n8n-mcp.com) as primary option - Self-hosting: Renamed options to A (npx), B (Docker), C (Local), D (Railway) - Removed: "Memory Leak Fix (v2.20.2)" section (outdated) - Removed: "Known Issues" section (outdated container management) - Claude Project Setup: Updated all tool references to v2.26.0 consolidated tools - validate_node({mode: 'minimal'|'full'}) instead of separate tools - search_templates({searchMode: ...}) unified template search - get_node({mode: 'docs'|'search_properties'}) for documentation - n8n_executions({action: ...}) unified execution management - Available MCP Tools: Updated to show 19 consolidated tools (7 core + 12 mgmt) - Recent Updates: Simplified to just link to CHANGELOG.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en * fix: update tool count from 31 to 19 in diagnostic message 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tests): update tool count expectations for v2.26.0 Update handlers-n8n-manager.test.ts to expect new consolidated tool counts (7/12/19) after v2.26.0 tool consolidation. Conceived by Romuald Członkowski - www.aiadvisors.pl/en 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
541 lines
18 KiB
TypeScript
541 lines
18 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
import { TestableN8NMCPServer } from './test-helpers';
|
|
|
|
describe('MCP Error Handling', () => {
|
|
let mcpServer: TestableN8NMCPServer;
|
|
let client: Client;
|
|
|
|
beforeEach(async () => {
|
|
mcpServer = new TestableN8NMCPServer();
|
|
await mcpServer.initialize();
|
|
|
|
const [serverTransport, clientTransport] = InMemoryTransport.createLinkedPair();
|
|
await mcpServer.connectToTransport(serverTransport);
|
|
|
|
client = new Client({
|
|
name: 'test-client',
|
|
version: '1.0.0'
|
|
}, {
|
|
capabilities: {}
|
|
});
|
|
|
|
await client.connect(clientTransport);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await client.close();
|
|
await mcpServer.close();
|
|
});
|
|
|
|
describe('JSON-RPC Error Codes', () => {
|
|
it('should handle invalid request (parse error)', async () => {
|
|
// The MCP SDK handles parsing, so we test with invalid method instead
|
|
try {
|
|
await (client as any).request({
|
|
method: '', // Empty method
|
|
params: {}
|
|
});
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
}
|
|
});
|
|
|
|
it('should handle method not found', async () => {
|
|
try {
|
|
await (client as any).request({
|
|
method: 'nonexistent/method',
|
|
params: {}
|
|
});
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
expect(error.message).toContain('not found');
|
|
}
|
|
});
|
|
|
|
it('should handle invalid params', async () => {
|
|
try {
|
|
// Missing required parameter
|
|
await client.callTool({ name: 'get_node', arguments: {} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
// The error now properly validates required parameters
|
|
expect(error.message).toContain("Missing required parameters");
|
|
}
|
|
});
|
|
|
|
it('should handle internal errors gracefully', async () => {
|
|
try {
|
|
// Invalid node type format should cause internal processing error
|
|
await client.callTool({ name: 'get_node', arguments: {
|
|
nodeType: 'completely-invalid-format-$$$$'
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
expect(error.message).toContain('not found');
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('Tool-Specific Errors', () => {
|
|
describe('Node Discovery Errors', () => {
|
|
it('should handle search with no matching results', async () => {
|
|
const response = await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: 'xyznonexistentnode123'
|
|
} });
|
|
|
|
// Should return empty array, not error
|
|
const result = JSON.parse((response as any).content[0].text);
|
|
expect(result).toHaveProperty('results');
|
|
expect(Array.isArray(result.results)).toBe(true);
|
|
expect(result.results).toHaveLength(0);
|
|
});
|
|
|
|
it('should handle invalid search mode', async () => {
|
|
try {
|
|
await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: 'test',
|
|
mode: 'INVALID_MODE' as any
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
}
|
|
});
|
|
|
|
it('should handle empty search query', async () => {
|
|
try {
|
|
await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: ''
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
expect(error.message).toContain("search_nodes: Validation failed:");
|
|
expect(error.message).toContain("query: query cannot be empty");
|
|
}
|
|
});
|
|
|
|
it('should handle non-existent node types', async () => {
|
|
try {
|
|
await client.callTool({ name: 'get_node', arguments: {
|
|
nodeType: 'nodes-base.thisDoesNotExist'
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
expect(error.message).toContain('not found');
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('Validation Errors', () => {
|
|
// v2.26.0: validate_node_operation consolidated into validate_node
|
|
it('should handle invalid validation profile', async () => {
|
|
try {
|
|
await client.callTool({ name: 'validate_node', arguments: {
|
|
nodeType: 'nodes-base.httpRequest',
|
|
config: { method: 'GET', url: 'https://api.example.com' },
|
|
mode: 'full',
|
|
profile: 'invalid_profile' as any
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
}
|
|
});
|
|
|
|
it('should handle malformed workflow structure', async () => {
|
|
try {
|
|
await client.callTool({ name: 'validate_workflow', arguments: {
|
|
workflow: {
|
|
// Missing required 'nodes' array
|
|
connections: {}
|
|
}
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
expect(error.message).toContain("validate_workflow: Validation failed:");
|
|
expect(error.message).toContain("workflow.nodes: workflow.nodes is required");
|
|
}
|
|
});
|
|
|
|
it('should handle circular workflow references', async () => {
|
|
const workflow = {
|
|
nodes: [
|
|
{
|
|
id: '1',
|
|
name: 'Node1',
|
|
type: 'nodes-base.noOp',
|
|
typeVersion: 1,
|
|
position: [0, 0],
|
|
parameters: {}
|
|
},
|
|
{
|
|
id: '2',
|
|
name: 'Node2',
|
|
type: 'nodes-base.noOp',
|
|
typeVersion: 1,
|
|
position: [250, 0],
|
|
parameters: {}
|
|
}
|
|
],
|
|
connections: {
|
|
'Node1': {
|
|
'main': [[{ node: 'Node2', type: 'main', index: 0 }]]
|
|
},
|
|
'Node2': {
|
|
'main': [[{ node: 'Node1', type: 'main', index: 0 }]]
|
|
}
|
|
}
|
|
};
|
|
|
|
const response = await client.callTool({ name: 'validate_workflow', arguments: {
|
|
workflow
|
|
} });
|
|
|
|
const validation = JSON.parse((response as any).content[0].text);
|
|
expect(validation.warnings).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('Documentation Errors', () => {
|
|
it('should handle non-existent documentation topics', async () => {
|
|
const response = await client.callTool({ name: 'tools_documentation', arguments: {
|
|
topic: 'completely_fake_tool'
|
|
} });
|
|
|
|
expect((response as any).content[0].text).toContain('not found');
|
|
});
|
|
|
|
it('should handle invalid depth parameter', async () => {
|
|
try {
|
|
await client.callTool({ name: 'tools_documentation', arguments: {
|
|
depth: 'invalid_depth' as any
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Large Payload Handling', () => {
|
|
it('should handle large node info requests', async () => {
|
|
// HTTP Request node has extensive properties
|
|
const response = await client.callTool({ name: 'get_node', arguments: {
|
|
nodeType: 'nodes-base.httpRequest',
|
|
detail: 'full'
|
|
} });
|
|
|
|
expect((response as any).content[0].text.length).toBeGreaterThan(10000);
|
|
|
|
// Should be valid JSON
|
|
const nodeInfo = JSON.parse((response as any).content[0].text);
|
|
expect(nodeInfo).toHaveProperty('nodeType');
|
|
expect(nodeInfo).toHaveProperty('displayName');
|
|
});
|
|
|
|
it('should handle large workflow validation', async () => {
|
|
// Create a large workflow
|
|
const nodes = [];
|
|
const connections: any = {};
|
|
|
|
for (let i = 0; i < 50; i++) {
|
|
const nodeName = `Node${i}`;
|
|
nodes.push({
|
|
id: String(i),
|
|
name: nodeName,
|
|
type: 'nodes-base.noOp',
|
|
typeVersion: 1,
|
|
position: [i * 100, 0],
|
|
parameters: {}
|
|
});
|
|
|
|
if (i > 0) {
|
|
const prevNode = `Node${i - 1}`;
|
|
connections[prevNode] = {
|
|
'main': [[{ node: nodeName, type: 'main', index: 0 }]]
|
|
};
|
|
}
|
|
}
|
|
|
|
const response = await client.callTool({ name: 'validate_workflow', arguments: {
|
|
workflow: { nodes, connections }
|
|
} });
|
|
|
|
const validation = JSON.parse((response as any).content[0].text);
|
|
expect(validation).toHaveProperty('valid');
|
|
});
|
|
|
|
it('should handle many concurrent requests', async () => {
|
|
const requestCount = 50;
|
|
const promises = [];
|
|
|
|
for (let i = 0; i < requestCount; i++) {
|
|
promises.push(
|
|
client.callTool({ name: 'search_nodes', arguments: {
|
|
query: i % 2 === 0 ? 'webhook' : 'http',
|
|
limit: 1
|
|
} })
|
|
);
|
|
}
|
|
|
|
const responses = await Promise.all(promises);
|
|
expect(responses).toHaveLength(requestCount);
|
|
});
|
|
});
|
|
|
|
describe('Invalid JSON Handling', () => {
|
|
// v2.26.0: validate_node_operation consolidated into validate_node
|
|
it('should handle invalid JSON in tool parameters', async () => {
|
|
try {
|
|
// Config should be an object, not a string
|
|
await client.callTool({ name: 'validate_node', arguments: {
|
|
nodeType: 'nodes-base.httpRequest',
|
|
config: 'invalid json string' as any,
|
|
mode: 'full'
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
}
|
|
});
|
|
|
|
it('should handle malformed workflow JSON', async () => {
|
|
try {
|
|
await client.callTool({ name: 'validate_workflow', arguments: {
|
|
workflow: 'not a valid workflow object' as any
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('Timeout Scenarios', () => {
|
|
it('should handle rapid sequential requests', async () => {
|
|
const start = Date.now();
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
await client.callTool({ name: 'tools_documentation', arguments: {} });
|
|
}
|
|
|
|
const duration = Date.now() - start;
|
|
|
|
// Should complete reasonably quickly (under 5 seconds)
|
|
expect(duration).toBeLessThan(5000);
|
|
});
|
|
|
|
it('should handle long-running operations', async () => {
|
|
// Search with complex query that requires more processing
|
|
const response = await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: 'a b c d e f g h i j k l m n o p q r s t u v w x y z',
|
|
mode: 'AND'
|
|
} });
|
|
|
|
expect(response).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('Memory Pressure', () => {
|
|
it('should handle multiple large responses', async () => {
|
|
const promises = [];
|
|
|
|
// Request multiple large node infos
|
|
const largeNodes = [
|
|
'nodes-base.httpRequest',
|
|
'nodes-base.postgres',
|
|
'nodes-base.googleSheets',
|
|
'nodes-base.slack',
|
|
'nodes-base.gmail'
|
|
];
|
|
|
|
for (const nodeType of largeNodes) {
|
|
promises.push(
|
|
client.callTool({ name: 'get_node', arguments: { nodeType } })
|
|
.catch(() => null) // Some might not exist
|
|
);
|
|
}
|
|
|
|
const responses = await Promise.all(promises);
|
|
const validResponses = responses.filter(r => r !== null);
|
|
|
|
expect(validResponses.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('should handle workflow with many nodes', async () => {
|
|
const nodeCount = 100;
|
|
const nodes = [];
|
|
|
|
for (let i = 0; i < nodeCount; i++) {
|
|
nodes.push({
|
|
id: String(i),
|
|
name: `Node${i}`,
|
|
type: 'nodes-base.noOp',
|
|
typeVersion: 1,
|
|
position: [i * 50, Math.floor(i / 10) * 100],
|
|
parameters: {
|
|
// Add some data to increase memory usage
|
|
data: `This is some test data for node ${i}`.repeat(10)
|
|
}
|
|
});
|
|
}
|
|
|
|
const response = await client.callTool({ name: 'validate_workflow', arguments: {
|
|
workflow: {
|
|
nodes,
|
|
connections: {}
|
|
}
|
|
} });
|
|
|
|
const validation = JSON.parse((response as any).content[0].text);
|
|
expect(validation).toHaveProperty('valid');
|
|
});
|
|
});
|
|
|
|
describe('Error Recovery', () => {
|
|
it('should continue working after errors', async () => {
|
|
// Cause an error
|
|
try {
|
|
await client.callTool({ name: 'get_node', arguments: {
|
|
nodeType: 'invalid'
|
|
} });
|
|
} catch (error) {
|
|
// Expected
|
|
}
|
|
|
|
// Should still work
|
|
const response = await client.callTool({ name: 'search_nodes', arguments: { query: 'webhook', limit: 1 } });
|
|
expect(response).toBeDefined();
|
|
});
|
|
|
|
it('should handle mixed success and failure', async () => {
|
|
const promises = [
|
|
client.callTool({ name: 'search_nodes', arguments: { query: 'webhook', limit: 5 } }),
|
|
client.callTool({ name: 'get_node', arguments: { nodeType: 'invalid' } }).catch(e => ({ error: e })),
|
|
client.callTool({ name: 'tools_documentation', arguments: {} }),
|
|
client.callTool({ name: 'search_nodes', arguments: { query: '' } }).catch(e => ({ error: e })),
|
|
client.callTool({ name: 'get_node', arguments: { nodeType: 'nodes-base.httpRequest' } })
|
|
];
|
|
|
|
const results = await Promise.all(promises);
|
|
|
|
// Some should succeed, some should fail
|
|
const successes = results.filter(r => !('error' in r));
|
|
const failures = results.filter(r => 'error' in r);
|
|
|
|
expect(successes.length).toBeGreaterThan(0);
|
|
expect(failures.length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
|
|
describe('Edge Cases', () => {
|
|
it('should handle empty responses gracefully', async () => {
|
|
const response = await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: 'xyznonexistentnode12345'
|
|
} });
|
|
|
|
const result = JSON.parse((response as any).content[0].text);
|
|
expect(result).toHaveProperty('results');
|
|
expect(Array.isArray(result.results)).toBe(true);
|
|
expect(result.results).toHaveLength(0);
|
|
});
|
|
|
|
it('should handle special characters in parameters', async () => {
|
|
const response = await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: 'test!@#$%^&*()_+-=[]{}|;\':",./<>?'
|
|
} });
|
|
|
|
// Should return results or empty array, not error
|
|
const result = JSON.parse((response as any).content[0].text);
|
|
expect(result).toHaveProperty('results');
|
|
expect(Array.isArray(result.results)).toBe(true);
|
|
});
|
|
|
|
it('should handle unicode in parameters', async () => {
|
|
const response = await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: 'test 测试 тест परीक्षण'
|
|
} });
|
|
|
|
const result = JSON.parse((response as any).content[0].text);
|
|
expect(result).toHaveProperty('results');
|
|
expect(Array.isArray(result.results)).toBe(true);
|
|
});
|
|
|
|
it('should handle null and undefined gracefully', async () => {
|
|
// Most tools should handle missing optional params
|
|
const response = await client.callTool({ name: 'search_nodes', arguments: {
|
|
query: 'webhook',
|
|
limit: undefined as any,
|
|
mode: null as any
|
|
} });
|
|
|
|
const result = JSON.parse((response as any).content[0].text);
|
|
expect(result).toHaveProperty('results');
|
|
expect(Array.isArray(result.results)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('Error Message Quality', () => {
|
|
it('should provide helpful error messages', async () => {
|
|
try {
|
|
// Use a truly invalid node type
|
|
await client.callTool({ name: 'get_node', arguments: {
|
|
nodeType: 'invalid-node-type-that-does-not-exist'
|
|
} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error.message).toBeDefined();
|
|
expect(error.message.length).toBeGreaterThan(10);
|
|
// Should mention the issue
|
|
expect(error.message.toLowerCase()).toMatch(/not found|invalid|missing/);
|
|
}
|
|
});
|
|
|
|
it('should indicate missing required parameters', async () => {
|
|
try {
|
|
await client.callTool({ name: 'search_nodes', arguments: {} });
|
|
expect.fail('Should have thrown an error');
|
|
} catch (error: any) {
|
|
expect(error).toBeDefined();
|
|
// The error now properly validates required parameters
|
|
expect(error.message).toContain("search_nodes: Validation failed:");
|
|
expect(error.message).toContain("query: query is required");
|
|
}
|
|
});
|
|
|
|
// v2.26.0: validate_node_operation consolidated into validate_node
|
|
it('should provide context for validation errors', async () => {
|
|
const response = await client.callTool({ name: 'validate_node', arguments: {
|
|
nodeType: 'nodes-base.httpRequest',
|
|
config: {
|
|
// Missing required fields
|
|
method: 'INVALID_METHOD'
|
|
},
|
|
mode: 'full'
|
|
} });
|
|
|
|
const validation = JSON.parse((response as any).content[0].text);
|
|
expect(validation.valid).toBe(false);
|
|
expect(validation.errors).toBeDefined();
|
|
expect(Array.isArray(validation.errors)).toBe(true);
|
|
expect(validation.errors.length).toBeGreaterThan(0);
|
|
if (validation.errors.length > 0) {
|
|
expect(validation.errors[0].message).toBeDefined();
|
|
// Field property might not exist on all error types
|
|
if (validation.errors[0].field !== undefined) {
|
|
expect(validation.errors[0].field).toBeDefined();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}); |