About Generate Unit Testing Server
An MCP server that detects Angular, React, and Next.js projects and generates unit tests using Jest, Karma/Jasmine, or Vitest. It also validates tests and reports coverage for developers reviewing generated code.
Key features
- 01Detects project and test framework
- 02Generates tests for public methods
- 03Supports Jest, Karma/Jasmine, and Vitest
- 04Runs tests and calculates coverage
- 05Shows source and test code side by side
Use cases
- 01Create tests for a React component
- 02Test Angular services and pipes
- 03Check generated tests and coverage
MCP support
Exposes project detection, test-framework installation, test generation, validation, and code comparison tools to MCP clients. It also provides testing documentation resources and test-generation prompts.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Generate Unit Testing Server
An intelligent Model Context Protocol (MCP) server that automatically generates comprehensive unit tests for Angular, React, and Next.js projects using Jest, Karma/Jasmine, or other testing frameworks.
Features
- 🔍 Automatic Project Detection - Detects Angular, React, or Next.js projects and their versions
- 📦 Framework Management - Checks for testing frameworks and offers automated installation
- 📚 Live Documentation Fetching - Retrieves latest Jest and Jasmine documentation before generating tests
- 🤖 LLM-Powered Generation - Uses Claude Sonnet 4.5+ for intelligent test generation
- 🎯 High Coverage Target - Generates tests targeting >85% code coverage
- ✅ All Public Methods - Creates tests for all exported functions and public class methods
- 🔄 Side-by-Side Validation - Displays source and test code for easy review
- 🛠️ Multiple Frameworks - Supports Jest, Karma/Jasmine, and Vitest
Installation
npm install
npm run build
Usage
As MCP Server
Add to your MCP client configuration (e.g., Claude Desktop, VS Code with MCP):
{
"mcpServers": {
"generate-unit-testing": {
"command": "node",
"args": ["/path/to/GenerateUnitTesting/build/index.js"]
}
}
}
Available Tools
1. detect_project
Detects the project type and testing framework.
{
"filePath": "/path/to/your/project/src/component.ts"
}
2. install_test_framework
Installs missing testing framework with user permission.
{
"projectPath": "/path/to/your/project",
"framework": "jest",
"autoInstall": false
}
3. generate_unit_test
Generates comprehensive unit tests for a source file.
{
"filePath": "/path/to/your/project/src/component.ts",
"framework": "jest",
"coverageTarget": 85,
"generateForAllPublicMethods": true,
"includeEdgeCases": true
}
4. validate_test
Runs generated tests and calculates coverage.
{
"testFilePath": "/path/to/your/project/src/component.test.ts",
"framework": "jest"
}
5. display_side_by_side
Creates side-by-side comparison of source and test code.
{
"sourceFilePath": "/path/to/your/project/src/component.ts",
"testFilePath": "/path/to/your/project/src/component.test.ts"
}
Available Resources
docs://jest/latest- Latest Jest documentationdocs://jasmine/latest- Latest Jasmine documentation
Available Prompts
generate-unit-test- Comprehensive unit test generation promptgenerate-edge-cases- Edge case test generation promptgenerate-mocks- Mock generation prompt
Architecture
src/
├── index.ts # Main MCP server entry point
├── types.ts # TypeScript type definitions
├── tools/
│ ├── detectProject.ts # Project and framework detection
│ └── testGenerator.ts # Test generation logic
├── resources/
│ └── documentationFetcher.ts # Live doc fetching from Jest/Jasmine
├── templates/
│ └── testTemplates.ts # Framework-specific test templates
├── prompts/
│ └── testPrompts.ts # LLM prompts for test generation
└── utils/
├── fileUtils.ts # File system utilities
└── codeAnalyzer.ts # AST-based code analysis
Workflow
- Project Detection - Analyzes
package.jsonto identify project type and existing test setup - Framework Check - Verifies testing framework installation, prompts for installation if missing
- Documentation Fetch - Retrieves latest framework documentation from official sources
- Code Analysis - Parses source code using Babel to extract functions, classes, and methods
- Test Generation - Uses LLM with context (code + docs + templates) to generate comprehensive tests
- Validation - Runs tests and calculates coverage
- Display - Shows side-by-side comparison for developer review
Supported Frameworks
Jest
- React and Next.js projects
- TypeScript/JavaScript
- Modern async/await patterns
- Mock functions and spies
Karma/Jasmine
- Angular projects
- Component testing with TestBed
- Service and pipe testing
- Traditional describe/it syntax
Coverage Goals
The server targets >85% code coverage by generating:
- Tests for all public functions
- Tests for all public class methods
- Edge case scenarios
- Error handling tests
- Async operation tests
- Mock implementations for dependencies
Example Output
For a React component:
// Original: Button.tsx
export const Button = ({ onClick, label }) => {
return <button onClick={onClick}>{label}</button>;
};
Generated test:
// Generated: Button.test.tsx
import { render, fireEvent } from '@testing-library/react';
import { Button } from './Button';
describe('Button', () => {
it('should render with label', () => {
const { getByText } = render(<Button label="Click me" onClick={() => {}} />);
expect(getByText('Click me')).toBeInTheDocument();
});
it('should call onClick when clicked', () => {
const handleClick = jest.fn();
const { getByText } = render(<Button label="Click me" onClick={handleClick} />);
fireEvent.click(getByText('Click me'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
// ... more tests for edge cases;
Requirements
- Node.js 18+
- TypeScript 5+
- MCP client (Claude Desktop, VS Code with MCP extension, etc.)
Development
# Install dependencies
npm install
# Build
npm run build
# Watch mode
npm run watch
# Start server
npm start
Configuration
The server automatically detects:
- Package manager (npm, yarn, pnpm)
- Project type (Angular, React, Next.js)
- Existing test framework
- TypeScript/JavaScript
No manual configuration required!
License
MIT
Contributing
Contributions welcome! Please ensure:
- Code follows existing patterns
- Tests are included for new features
- Documentation is updated
Support
- For issues or questions, please open an issue on the repository.
- Author: Ahmadreza Shamimi (https://github.com/shentia)
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.