detox_validate_config
Validate Detox configuration files to identify errors and warnings before running mobile tests.
Instructions
Validate Detox configuration for errors and warnings.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | No | Path to project root | |
| configuration | No | Specific configuration to validate |
Implementation Reference
- src/tools/index.ts:233-259 (handler)Main handler implementation for the 'detox_validate_config' tool. Reads the Detox config and validates it using the imported validateConfig helper.export const validateConfigTool: Tool = { name: "detox_validate_config", description: "Validate Detox configuration for errors and warnings.", inputSchema: zodToJsonSchema(ValidateConfigArgsSchema), handler: async (args: z.infer<typeof ValidateConfigArgsSchema>) => { const parsed = ValidateConfigArgsSchema.parse(args); const projectPath = parsed.projectPath || process.cwd(); const result = await readDetoxConfig(projectPath); if (!result) { return { success: false, valid: false, errors: ["No Detox configuration found."], warnings: [], }; } const validation = validateConfig(result.config); return { success: true, ...validation, }; }, };
- src/utils/validators.ts:61-66 (schema)Zod input schema for the detox_validate_config tool arguments.export const ValidateConfigArgsSchema = z.object({ projectPath: z.string().optional().describe("Path to project root"), configuration: z.string().optional().describe("Specific configuration to validate"), }); export type ValidateConfigArgs = z.infer<typeof ValidateConfigArgsSchema>;
- src/utils/config-parser.ts:153-220 (helper)Core validation logic function that checks Detox config for errors and warnings, used by the tool handler.export function validateConfig(config: DetoxConfig): { valid: boolean; errors: string[]; warnings: string[]; } { const errors: string[] = []; const warnings: string[] = []; // Check for required sections if (!config.configurations || Object.keys(config.configurations).length === 0) { errors.push("No configurations defined"); } if (!config.devices || Object.keys(config.devices).length === 0) { errors.push("No devices defined"); } if (!config.apps || Object.keys(config.apps).length === 0) { errors.push("No apps defined"); } // Validate each configuration if (config.configurations) { for (const [name, conf] of Object.entries(config.configurations)) { if (!config.devices?.[conf.device]) { errors.push(`Configuration "${name}" references undefined device "${conf.device}"`); } if (!config.apps?.[conf.app]) { errors.push(`Configuration "${name}" references undefined app "${conf.app}"`); } } } // Validate apps have build commands if (config.apps) { for (const [name, app] of Object.entries(config.apps)) { if (!app.binaryPath) { errors.push(`App "${name}" is missing binaryPath`); } if (!app.build) { warnings.push(`App "${name}" has no build command defined`); } } } // Validate device types const validDeviceTypes = [ "ios.simulator", "ios.device", "android.emulator", "android.attached", "android.genycloud", ]; if (config.devices) { for (const [name, device] of Object.entries(config.devices)) { if (!validDeviceTypes.includes(device.type)) { warnings.push(`Device "${name}" has unknown type "${device.type}"`); } } } return { valid: errors.length === 0, errors, warnings, }; }
- src/tools/index.ts:429-442 (registration)The tool is registered in the allTools export array, likely used for MCP tool registration.export const allTools: Tool[] = [ buildTool, testTool, initTool, readConfigTool, listConfigurationsTool, validateConfigTool, createConfigTool, listDevicesTool, generateTestTool, generateMatcherTool, generateActionTool, generateExpectationTool, ];