get_test_summary
Generate a detailed summary of test setups, coverage metrics, and actionable recommendations for JavaScript/TypeScript projects by specifying the repository path.
Instructions
Get a comprehensive summary of the test setup, coverage, and recommendations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repoPath | Yes | Path to the repository |
Implementation Reference
- src/index.ts:138-151 (registration)Registration of the get_test_summary tool in the ListToolsRequestSchema response, including name, description, and input schema definition.{ name: 'get_test_summary', description: 'Get a comprehensive summary of the test setup, coverage, and recommendations', inputSchema: { type: 'object', properties: { repoPath: { type: 'string', description: 'Path to the repository', }, }, required: ['repoPath'], }, },
- src/index.ts:161-162 (registration)Dispatch registration in the CallToolRequestSchema switch statement that routes calls to the getTestSummary handler method.case 'get_test_summary': return await this.getTestSummary(request.params.arguments);
- src/index.ts:141-150 (schema)Input schema definition for the get_test_summary tool, specifying the repoPath parameter.inputSchema: { type: 'object', properties: { repoPath: { type: 'string', description: 'Path to the repository', }, }, required: ['repoPath'], },
- src/index.ts:300-342 (handler)The primary handler function for the get_test_summary tool. It validates input, calls analyzeTestSetup and checkCoverage internally, and generates a comprehensive summary report using generateComprehensiveSummary.private async getTestSummary(args: any) { if (!args.repoPath || typeof args.repoPath !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'repoPath is required'); } try { const repoPath = path.resolve(args.repoPath); // Get test setup analysis const setupResult = await this.analyzeTestSetup({ repoPath }); const setup = JSON.parse(setupResult.content[0].text); // Get coverage data const coverageResult = await this.checkCoverage({ repoPath, runTests: false }); const coverage = coverageResult.content[0].text.includes('No coverage data') ? null : JSON.parse(coverageResult.content[0].text); // Generate comprehensive summary const summary = this.generateComprehensiveSummary(setup, coverage); return { content: [ { type: 'text', text: summary, }, ], }; } catch (error) { if (error instanceof McpError) throw error; return { content: [ { type: 'text', text: `Error generating summary: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/index.ts:688-773 (helper)Key helper function called by the handler to generate the comprehensive markdown-formatted test analysis report, including setup, coverage, dependencies, and recommendations.private generateComprehensiveSummary(setup: TestAnalysisResult, coverage: CoverageResult | null): string { let summary = `# Test Analysis Report\n\n`; // Test Setup Section summary += `## Test Setup\n\n`; summary += `- **Framework**: ${setup.framework || 'None detected'}\n`; summary += `- **Test Files**: ${setup.testFiles.length}\n`; summary += `- **Total Tests**: ${setup.testCount}\n`; summary += `- **Test Suites**: ${setup.testStructure.suites}\n`; if (setup.testStructure.hooks.length > 0) { summary += `- **Hooks Used**: ${setup.testStructure.hooks.join(', ')}\n`; } // Coverage Section summary += `\n## Coverage\n\n`; if (coverage) { summary += coverage.summary; } else { summary += `No coverage data available. Run tests with coverage to generate metrics.\n`; } // Dependencies Section if (setup.dependencies.length > 0) { summary += `\n## Test Dependencies\n\n`; const mainDeps = ['jest', 'vitest', 'mocha', 'cypress', 'playwright']; const mainFound = setup.dependencies.filter((d: string) => mainDeps.some((m: string) => d.startsWith(m))); if (mainFound.length > 0) { summary += `**Main Testing Frameworks**:\n`; mainFound.forEach((dep: string) => summary += `- ${dep}\n`); } const utilDeps = setup.dependencies.filter((d: string) => !mainFound.includes(d)); if (utilDeps.length > 0) { summary += `\n**Testing Utilities**:\n`; utilDeps.slice(0, 5).forEach((dep: string) => summary += `- ${dep}\n`); if (utilDeps.length > 5) { summary += `- ... and ${utilDeps.length - 5} more\n`; } } } // Recommendations Section summary += `\n## Recommendations\n\n`; const recommendations: string[] = []; if (!setup.framework) { recommendations.push('🔴 No test framework detected. Consider setting up Jest, Vitest, or another testing framework.'); } if (setup.testFiles.length === 0) { recommendations.push('🔴 No test files found. Start writing tests for your code.'); } else if (setup.testCount < 10) { recommendations.push('🟡 Low test count. Consider adding more test coverage.'); } if (!coverage) { recommendations.push('🟡 No coverage data available. Configure coverage reporting in your test setup.'); } else { if (coverage.lines.percentage < 60) { recommendations.push('🔴 Line coverage is below 60%. Aim for at least 80% coverage.'); } else if (coverage.lines.percentage < 80) { recommendations.push('🟡 Line coverage is below 80%. Consider adding more tests.'); } if (coverage.branches.percentage < 60) { recommendations.push('🟡 Branch coverage is low. Add tests for different code paths.'); } } if (Object.keys(setup.coverageConfig).length === 0) { recommendations.push('🟡 No coverage configuration found. Set up coverage reporting.'); } if (recommendations.length === 0) { recommendations.push('✅ Test setup looks good! Keep maintaining high standards.'); } recommendations.forEach((rec: string) => { summary += `- ${rec}\n`; }); return summary; }