Skip to main content
Glama
andreahaku
by andreahaku

ui.assert_text

Verify UI elements display expected text content in iOS Simulator during React Native/Expo testing. Specify element selector and text to validate exact or partial matches.

Instructions

Assert that an element has specific text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesElement selector.
textYesExpected text content.
exactNoExact match (true) or contains (false).

Implementation Reference

  • Registration and inline handler implementation for the 'ui.assert_text' tool. Generates a Detox snippet for text assertion and executes it via runDetoxAction, returning the result.
    server.tool( "ui.assert_text", "Assert that an element has specific text content", UiAssertTextInputSchema.shape, async (args) => { try { const snippet = generateAssertTextSnippet({ selector: args.selector, text: args.text, exact: args.exact, }); const result = await runDetoxAction({ actionName: `assertText:${describeSelector(args.selector)}`, actionSnippet: snippet, }); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; } catch (error) { return handleToolError(error); } } );
  • Zod input schema defining parameters for the ui.assert_text tool: selector, text, and optional exact match flag.
    export const UiAssertTextInputSchema = z.object({ selector: SelectorSchema.describe("Element selector."), text: z.string().describe("Expected text content."), exact: z.boolean().optional().default(true).describe("Exact match (true) or contains (false)."), });
  • Helper function that generates the Detox code snippet for asserting text content on a UI element, supporting exact or partial matches.
    export function generateAssertTextSnippet(options: AssertTextOptions): string { const el = buildElementExpr(options.selector); const escapedText = JSON.stringify(options.text); if (options.exact !== false) { return `await expect(${el}).toHaveText(${escapedText});`; } // For partial text match, we use toHaveText with regex return `await expect(${el}).toHaveText(new RegExp(${escapedText}));`; }

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/andreahaku/expo_ios_development_mcp'

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