Skip to main content
Glama
lucad87

MCP Server - Test Migration (WDIO to Playwright)

by lucad87

migrate_to_playwright

Convert WebDriverIO tests to Playwright syntax using AST transformation. Supports partial migrations, preserves existing code, and generates TypeScript or JavaScript output.

Instructions

Migrates a WebDriverIO test to Playwright syntax using AST transformation. Supports partial migrations and preserves already-migrated code. Uses modern Playwright locators (getByRole, getByLabel, getByTestId with data-test-id). Supports TypeScript output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testContentYesThe WDIO test content to migrate
analysisResultNoOptional JSON string of previous analysis result to use as context
filePathNoOriginal file path for naming reference
outputFormatNoOutput format: javascript (default) or typescript

Implementation Reference

  • The `handleMigrateToPlaywright` function performs the migration of WDIO test content to Playwright using AST transformations.
    export async function handleMigrateToPlaywright(args) {
      const { testContent, analysisResult, filePath = 'test.spec.js', outputFormat = 'javascript' } = args;
    
      let analysis = null;
      if (analysisResult) {
        try {
          analysis = JSON.parse(analysisResult);
        } catch (e) {
          // Continue without analysis
        }
      }
    
      const isTypeScript = outputFormat === 'typescript' || filePath.endsWith('.ts');
      const migration = performAstMigration(testContent, analysis, isTypeScript);
      
      let targetFile = filePath;
      if (isTypeScript) {
        targetFile = filePath.replace(/\.(js|ts)$/, '.spec.ts');
      } else {
        targetFile = filePath.replace(/\.(js|ts)$/, '.spec.js');
      }
    
      const codeLanguage = isTypeScript ? 'typescript' : 'javascript';
    
      return {
        content: [{
          type: 'text',
          text: `# Migrated Playwright Test
    
    ## Original File: ${filePath}
    ## Target: ${targetFile}
    ## Format: ${isTypeScript ? 'TypeScript' : 'JavaScript'}
    
    ### Migration Summary:
    ${migration.notes.join('\n')}
    
    ### Migrated Code:
    
    \`\`\`${codeLanguage}
    ${migration.code}
    \`\`\`
    
    ### Next Steps:
    1. Review the migrated test for any manual adjustments needed
    2. Run \`npx playwright test ${targetFile}\` to verify functionality
    3. Use 'refactor_to_pom' tool to apply Page Object Model pattern
    4. Consider replacing CSS selectors with data-test-id attributes
    ${isTypeScript ? '5. Ensure tsconfig.json is properly configured for Playwright' : ''}
    `,
        }],
      };
    }
Behavior3/5

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

Without annotations, the description carries the full burden. It discloses key behavioral traits: AST transformation (implementation approach), preservation of existing code (safety/idempotency), and partial migration support. However, it fails to disclose critical operational details like whether the tool returns transformed content as a string or writes to disk, or what happens on parse errors.

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?

Four sentences with zero waste: core purpose (sentence 1), idempotency behavior (sentence 2), implementation specifics (sentence 3), and output format support (sentence 4). Front-loaded with the essential verb and resource, making it immediately scannable.

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

Completeness4/5

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

Given the 100% schema coverage and moderate complexity (4 parameters, no nested objects), the description provides adequate context about the migration approach and safety characteristics. However, lacking an output schema, it should ideally disclose the return format (transformed code string) and whether filePath is used for resolution or purely metadata.

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?

With 100% schema description coverage, the schema adequately documents all four parameters. The description reinforces the TypeScript output option and implies testContent should be parseable code via 'AST transformation,' but adds minimal semantic detail beyond what the structured schema already provides. Baseline score appropriate.

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

Purpose5/5

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

The description clearly states the specific action (migrates), source (WebDriverIO test), target (Playwright syntax), and method (AST transformation). It distinguishes from siblings like migrate_config (tests vs config) and refactor_to_pom (syntax migration vs POM refactoring) by specifying AST-based code transformation.

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

Usage Guidelines3/5

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

The description implies iterative usage through 'supports partial migrations and preserves already-migrated code,' suggesting idempotent behavior. The optional analysisResult parameter hints at workflow integration with analyze_wdio_test. However, it lacks explicit when-to-use guidance versus alternatives like refactor_to_pom or prerequisites for the migration.

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/lucad87/mcp-server-tests-migration'

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