Run Jest tests via MCP
## Jest MCP Server: Comprehensive JavaScript Testing Framework The **Jest MCP Server** integrates the powerful Jest testing framework into Google Antigravity, enabling intelligent test execution, coverage analysis, and test-driven development workflows through AI-assisted testing. ### Why Jest MCP? - **Smart Test Running**: Execute specific tests, test suites, or changed tests with intelligent filtering and watch mode - **Snapshot Testing**: Manage UI component snapshots with automatic updates and diff visualization - **Coverage Reports**: Generate detailed coverage reports with line-by-line analysis and threshold enforcement - **Mock Management**: Create, configure, and manage mocks for external dependencies and modules - **Parallel Execution**: Run tests in parallel for faster feedback on large test suites ### Key Features #### 1. Test Execution ```python from anthropic import Anthropic client = Anthropic() response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Run all tests related to the authentication module and show detailed results" }] ) ``` #### 2. Coverage Analysis ```python # Generate coverage report response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Show coverage report for src/services/ and identify uncovered functions" }] ) ``` #### 3. Snapshot Management ```python # Handle snapshot updates response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Show snapshot diff for Header component and update if the changes are intentional" }] ) ``` #### 4. Test Generation ```python # Generate test cases response = client.messages.create( model="claude-sonnet-4-20250514", max_tokens=1024, messages=[{ "role": "user", "content": "Generate Jest tests for the calculateTotal function covering edge cases" }] ) ``` ### Configuration ```json { "mcpServers": { "jest": { "command": "npx", "args": ["-y", "@anthropic/mcp-server-jest"], "env": { "JEST_CONFIG_PATH": "jest.config.js", "JEST_COVERAGE_THRESHOLD": "80" } } } } ``` ### Use Cases **Test-Driven Development**: Write and run tests iteratively as you develop features with immediate feedback. **Regression Prevention**: Run affected tests automatically when code changes to catch regressions early. **CI/CD Integration**: Enforce test pass rates and coverage thresholds as deployment gates. **Refactoring Safety**: Verify existing functionality remains intact during major code refactoring efforts. The Jest MCP Server brings testing into the AI-assisted development workflow, making it easier to write, run, and maintain comprehensive test suites that ensure code quality.
{
"mcpServers": {
"jest": {
"mcpServers": {
"jest": {
"args": [
"-y",
"jest-mcp-server"
],
"command": "npx"
}
}
}
}
}