run_tests
Execute standardized project tests with coverage when no specific pattern is provided, ensuring code quality through automated validation.
Instructions
Run standardized tests for the project (with coverage when no pattern specified)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | Test file pattern to match (runs coverage mode if omitted) |
Implementation Reference
- src/tools/runTests.ts:6-24 (handler)The RunTestsTool class extends BaseExecTool and defines the core logic for building the shell command to run tests, either with coverage (no pattern) or matching a specific pattern using the project's test command.class RunTestsTool extends BaseExecTool<TestRunnerOptions> { protected getActionName(): string { return 'Test'; } protected async buildCommand(args: TestRunnerOptions): Promise<string> { const { pattern } = args; const config = await loadProjectConfig(); // If no pattern specified, run tests with coverage if (!pattern) { return 'npm run test:coverage'; } // Otherwise run the configured test command with the pattern const command = config.testCommand ?? 'npm test'; return `${command} ${pattern}`; } }
- src/index.ts:71-80 (registration)Registers the 'run_tests' tool with the MCP server, providing description, Zod input schema, and the handler function that delegates to runTests.server.registerTool( 'run_tests', { description: 'Run standardized tests for the project (with coverage when no pattern specified)', inputSchema: { pattern: z.string().optional().describe('Test file pattern to match (runs coverage mode if omitted)'), }, }, async (args) => runTests(args) );
- src/types/index.ts:50-52 (schema)TypeScript interface defining the input shape for TestRunnerOptions used by the run_tests tool.export interface TestRunnerOptions { pattern?: string; }
- src/tools/runTests.ts:26-30 (handler)The exported runTests function instantiates the tool and executes it, serving as the direct handler called by the registration.const tool = new RunTestsTool(); export async function runTests(args: TestRunnerOptions): Promise<CallToolResult> { return tool.execute(args); }