Skip to main content
Glama

detox_generate_test

Create Detox test files for React Native apps by describing test scenarios in natural language. Generates complete E2E test code from descriptions to automate mobile testing.

Instructions

Generate a complete Detox test file from a description.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesNatural language description of the test scenario
testNameYesName for the test/describe block
outputPathNoWhere to write the generated test file
includeSetupNo
platformNocross-platform

Implementation Reference

  • The main handler function for the 'detox_generate_test' tool. It parses input arguments, generates a test file template using generateTestFileTemplate, optionally writes it to a file, and returns the generated code.
    export const generateTestTool: Tool = {
      name: "detox_generate_test",
      description: "Generate a complete Detox test file from a description.",
      inputSchema: zodToJsonSchema(GenerateTestArgsSchema),
      handler: async (args: z.infer<typeof GenerateTestArgsSchema>) => {
        const parsed = GenerateTestArgsSchema.parse(args);
    
        const testCode = generateTestFileTemplate({
          testName: parsed.testName,
          describeName: parsed.testName,
          includeSetup: parsed.includeSetup,
          tests: [
            {
              name: parsed.description,
              code: `    // Test: ${parsed.description}\n    // TODO: Implement test based on the description above`,
            },
          ],
        });
    
        if (parsed.outputPath) {
          await writeFile(parsed.outputPath, testCode, "utf-8");
        }
    
        return {
          success: true,
          code: testCode,
          outputPath: parsed.outputPath,
        };
      },
    };
  • Zod schema defining the input parameters for the detox_generate_test tool, including test description, name, output path, setup inclusion, and platform.
    // Generate test schema
    export const GenerateTestArgsSchema = z.object({
      description: z.string().describe("Natural language description of the test scenario"),
      testName: z.string().describe("Name for the test/describe block"),
      outputPath: z.string().optional().describe("Where to write the generated test file"),
      includeSetup: z.boolean().optional().default(true),
      platform: z.enum(["ios", "android", "cross-platform"]).optional().default("cross-platform"),
    });
    
    export type GenerateTestArgs = z.infer<typeof GenerateTestArgsSchema>;
  • Core helper function that generates the Detox test file template code, including describe block, beforeAll/beforeEach hooks, and it test stubs. Called by the tool handler.
    export function generateTestFileTemplate(options: {
      testName: string;
      describeName?: string;
      includeSetup?: boolean;
      tests?: Array<{ name: string; code: string }>;
    }): string {
      const describeName = options.describeName || options.testName;
      const tests = options.tests || [
        { name: "should work correctly", code: "    // TODO: Add test implementation" },
      ];
    
      const testCases = tests
        .map(
          (t) => `
      it('${t.name}', async () => {
    ${t.code}
      });`
        )
        .join("\n");
    
      if (options.includeSetup !== false) {
        return `describe('${describeName}', () => {
      beforeAll(async () => {
        await device.launchApp();
      });
    
      beforeEach(async () => {
        await device.reloadReactNative();
      });
    ${testCases}
    });
    `;
      }
    
      return `describe('${describeName}', () => {
    ${testCases}
    });
    `;
    }
  • The allTools array exports the generateTestTool (at index position line 438), registering it for use in the MCP tools system.
    export const allTools: Tool[] = [
      buildTool,
      testTool,
      initTool,
      readConfigTool,
      listConfigurationsTool,
      validateConfigTool,
      createConfigTool,
      listDevicesTool,
      generateTestTool,
      generateMatcherTool,
      generateActionTool,
      generateExpectationTool,
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool generates a test file but doesn't disclose behavioral traits such as file system effects (e.g., overwriting existing files), required dependencies, error handling, or output format. This is inadequate for a tool that likely writes files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every part earns its place by clearly stating the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and incomplete parameter documentation, the description is insufficient. It doesn't explain what a 'complete Detox test file' includes, how generation works, or what happens upon execution. For a tool with 5 parameters and likely file system operations, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 60%, with parameters like 'description' and 'testName' documented but others like 'outputPath' lacking descriptions. The description adds no additional parameter meaning beyond the schema, such as explaining what 'includeSetup' or 'platform' entail. Baseline 3 is appropriate given partial schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('generate') and resource ('complete Detox test file'), specifying it creates a test file from a description. It distinguishes from siblings like detox_generate_action or detox_generate_expectation by focusing on a full test file, but doesn't explicitly contrast with them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like detox_generate_action for partial components or detox_test for running tests. The description implies usage for creating test files from descriptions but offers no context about prerequisites, dependencies, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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