Skip to main content
Glama

detox_test

Execute end-to-end mobile tests for React Native applications with configurable options for device setup, retries, and artifact collection.

Instructions

Run Detox E2E tests with full options for configuration, retries, artifacts, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configurationNoDevice configuration name
testFilePathsNoSpecific test files to run
testNamePatternNoRegex pattern to filter tests
deviceNameNoOverride device name
loglevelNoinfo
retriesNoNumber of times to retry failing tests
reuseNoReuse existing app installation
headlessNoRun in headless mode
recordLogsNofailing
takeScreenshotsNofailing
recordVideosNonone
artifactsLocationNoCustom path for artifacts
cleanupNoShutdown simulator after tests
cwdNoWorking directory

Implementation Reference

  • The complete tool definition for 'detox_test', including name, description, input schema reference, and the handler function that constructs and executes the 'detox test' CLI command with all supported options, parses results, and returns structured output including test summary and artifacts info.
    export const testTool: Tool = { name: "detox_test", description: "Run Detox E2E tests with full options for configuration, retries, artifacts, and more.", inputSchema: zodToJsonSchema(TestArgsSchema), handler: async (args: z.infer<typeof TestArgsSchema>) => { const parsed = TestArgsSchema.parse(args); const cliArgs: string[] = ["test"]; if (parsed.configuration) { cliArgs.push("-c", parsed.configuration); } if (parsed.loglevel) { cliArgs.push("-l", parsed.loglevel); } if (parsed.retries !== undefined) { cliArgs.push("--retries", String(parsed.retries)); } if (parsed.reuse) { cliArgs.push("--reuse"); } if (parsed.headless) { cliArgs.push("--headless"); } if (parsed.recordLogs) { cliArgs.push("--record-logs", parsed.recordLogs); } if (parsed.takeScreenshots) { cliArgs.push("--take-screenshots", parsed.takeScreenshots); } if (parsed.recordVideos) { cliArgs.push("--record-videos", parsed.recordVideos); } if (parsed.artifactsLocation) { cliArgs.push("--artifacts-location", parsed.artifactsLocation); } if (parsed.cleanup) { cliArgs.push("--cleanup"); } if (parsed.deviceName) { cliArgs.push("--device-name", parsed.deviceName); } if (parsed.testNamePattern) { cliArgs.push("--testNamePattern", parsed.testNamePattern); } // Add test file paths at the end if (parsed.testFilePaths && parsed.testFilePaths.length > 0) { cliArgs.push("--", ...parsed.testFilePaths); } const result = await executeDetoxCommand(cliArgs, { cwd: parsed.cwd, timeout: 600000, // 10 minutes for tests }); // Parse test results from output const passMatch = result.stdout.match(/(\d+) passed/); const failMatch = result.stdout.match(/(\d+) failed/); const skipMatch = result.stdout.match(/(\d+) skipped/); return { success: result.success, summary: { passed: passMatch ? parseInt(passMatch[1]) : 0, failed: failMatch ? parseInt(failMatch[1]) : 0, skipped: skipMatch ? parseInt(skipMatch[1]) : 0, }, output: result.stdout, errors: result.stderr, duration: `${(result.duration / 1000).toFixed(1)}s`, artifactsLocation: parsed.artifactsLocation || "./artifacts", }; }, };
  • Zod schema (TestArgsSchema) defining all input parameters for the detox_test tool, with descriptions, defaults, and types for validation and MCP inputSchema generation.
    // Test tool schema export const TestArgsSchema = z.object({ configuration: z.string().optional().describe("Device configuration name"), testFilePaths: z.array(z.string()).optional().describe("Specific test files to run"), testNamePattern: z.string().optional().describe("Regex pattern to filter tests"), deviceName: z.string().optional().describe("Override device name"), loglevel: z .enum(["fatal", "error", "warn", "info", "verbose", "trace"]) .optional() .default("info"), retries: z.number().optional().describe("Number of times to retry failing tests"), reuse: z.boolean().optional().describe("Reuse existing app installation"), headless: z.boolean().optional().describe("Run in headless mode"), recordLogs: z.enum(["failing", "all", "none"]).optional().default("failing"), takeScreenshots: z.enum(["manual", "failing", "all", "none"]).optional().default("failing"), recordVideos: z.enum(["failing", "all", "none"]).optional().default("none"), artifactsLocation: z.string().optional().describe("Custom path for artifacts"), cleanup: z.boolean().optional().describe("Shutdown simulator after tests"), cwd: z.string().optional().describe("Working directory"), }); export type TestArgs = z.infer<typeof TestArgsSchema>;
  • src/index.ts:40-48 (registration)
    MCP server ListTools request handler that registers and exposes the detox_test tool (via allTools) with its name, description, and schema to MCP clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools.map((tool) => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema, })), }; });
  • src/index.ts:50-94 (registration)
    MCP server CallTool request handler that dispatches calls to the detox_test handler by looking up the tool by name in allTools and executing it with arguments.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const tool = allTools.find((t) => t.name === name); if (!tool) { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`); } try { // Add project path to args if not specified const argsWithPath = { ...args, cwd: (args as any)?.cwd || PROJECT_PATH, projectPath: (args as any)?.projectPath || PROJECT_PATH, }; const result = await tool.handler(argsWithPath); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: "text", text: JSON.stringify( { success: false, error: error.message, }, null, 2 ), }, ], isError: true, }; } });
  • Central registry of all tools including detox_test (as testTool), exported for use in MCP server.
    export const allTools: Tool[] = [ buildTool, testTool, initTool, readConfigTool, listConfigurationsTool, validateConfigTool, createConfigTool, listDevicesTool, generateTestTool, generateMatcherTool, generateActionTool, generateExpectationTool, ];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gayancliyanage/detox-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server