Cypress Test Generator logo

Cypress Test Generator

Community
jprealini

Automates Cypress test generation by analyzing web pages with Puppeteer to extract DOM elements and generate structured page object models with appropriate selectors and test patterns for end-to-end test automation.

Publisherjprealini
Repositorycypress-mcp
LanguageJavaScript
Forks
6
Stars
22
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Cypress Test Generator exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    22 stars and 6 forks from the linked repository.

MCP Cypress Page Object Generator

This MCP server automatically generates Cypress Page Object classes for any web page provided.

NPM package:

npm version

Features

  • Web Scraping: Uses Puppeteer to fetch and render web pages
  • HTML Parsing: Uses Cheerio to parse HTML and extract element information
  • Page Object Generation: Creates complete TypeScript Page Object classes with:
    • Private element locators
    • Public getter methods
    • Interaction methods (click, type, select, etc.)

Sample prompt:

Create a page object file using the following url: https://www.saucedemo.com/ 

Generated Output

The server generates:

1. Page Object Class ({ClassName}.ts)

typescript
export class ExampleComLoginPage {
  // Private elements
  #elements = {
    button_login: () => cy.get('#login-button'),
    input_username: () => cy.get('input[name="username"]'),
    link_home: () => cy.contains('a', 'Home')
  }

  // Public getters
  get ButtonLogin() { return this.#elements.button_login() }
  get InputUsername() { return this.#elements.input_username() }
  get LinkHome() { return this.#elements.link_home() }

  // Interaction methods
  clickButtonLogin() { return this.#elements.button_login().click() }
  typeInputUsername(text: string) { return this.#elements.input_username().type(text) }
  clickLinkHome() { return this.#elements.link_home().click() }

}

Element Types Supported

  • Buttons: Click interactions with validation
  • Input Fields: Type, clear, check/uncheck (for checkboxes/radio)
  • Links: Click interactions with navigation verification
  • Select Dropdowns: Select options with validation
  • Textareas: Type and clear with content verification
  • Forms: Submit interactions with success/error handling

Installation

Follow standard procedures to install an MCP in the client of your choice

Usage

  1. Start the server:

    bash
    node index.js
  2. Use with an MCP client: The server exposes a generatePageObjectFile tool that accepts a URL parameter.

    Example tool call:

    json
    {
      "method": "tools/call",
      "params": {
        "name": "generatePageObjectFile",
        "arguments": {
          "url": "https://example.com/login"
        }
      }
    }
  3. Response format: The server returns both the Page Object class:

    // ===== PAGE OBJECT CLASS =====
    // Save this as: ExampleComLoginPage.ts
    export class ExampleComLoginPage { ... } 
    

Dependencies

  • @modelcontextprotocol/sdk: MCP server implementation
  • puppeteer: Web scraping and page rendering
  • cheerio: HTML parsing and element selection
  • zod: Schema validation
  • typescript: Type safety

Error Handling

The server includes comprehensive error handling for:

  • Invalid URLs
  • Network connectivity issues
  • Page loading failures
  • HTML parsing errors

Browser Configuration

The server uses Puppeteer with the following settings:

  • Headless mode for server environments
  • No-sandbox mode for containerized deployments
  • Network idle waiting for dynamic content

Contributing

To add support for new element types, interaction methods, or test patterns, modify the generatePageObjectClass function in index.js.

Troubleshooting: Updating to the Latest MCP Version

If you are intending to update to the latest version of this MCP server package but the new version is not being pulled by npm, try this:

  1. Clear the NPM cache and reinstall the package:
    sh
    npm cache clean --force
    npm install @jprealini/cypress-mcp@latest --save-dev
  2. If using a lockfile (package-lock.json or yarn.lock), delete it and run:
    sh
    npm install
  3. For global installs, update globally:
    sh
    npm install -g @jprealini/cypress-mcp@latest
  4. Verify the installed version:
    sh
    npm list @jprealini/cypress-mcp

These steps ensure consumers always get the latest published MCP version and avoid issues with cached or locked old versions.

Example: Generated Page Object Format (saucedemo.com)

Below is an example of the expected Page Object format generated by MCP for saucedemo.com:

js
export class Swag_labsPage {
  // Private elements
  #elements = {
    inputUsername: () => cy.get('[data-test="username"]'),
    inputPassword: () => cy.get('[data-test="password"]'),
    inputLoginButton: () => cy.get('[data-test="login-button"]')
  }

  // Element meta (currently not used for bulk actions)

  // Public getters
  get inputUsername() { return this.#elements.inputUsername() }
  get inputPassword() { return this.#elements.inputPassword() }
  get inputLoginButton() { return this.#elements.inputLoginButton() }

  // Value/State getters
  getValueInputUsername() { return this.#elements.inputUsername().invoke('val') }
  getValueInputPassword() { return this.#elements.inputPassword().invoke('val') }
  getTextInputLoginButton() { return this.#elements.inputLoginButton().invoke('text') }

  // Interaction methods (per-element actions)
  typeInputUsername(text) { return this.#elements.inputUsername().type(text) }
  clearInputUsername() { return this.#elements.inputUsername().clear() }
  typeInputPassword(text) { return this.#elements.inputPassword().type(text) }
  clearInputPassword() { return this.#elements.inputPassword().clear() }
  clickInputLoginButton() { return this.#elements.inputLoginButton().click() }
}

This format follows one of the mostly used page object standards, using data attributes for selectors, private element encapsulation, public getters, value/state getters, and interaction methods for each element.

If you need or expect a different pattern, you can generate this base structure using this MCP, and then use your own instruction set to edit it to fit your needs, using a prompt like:

Create a page object file using the following url: https://www.saucedemo.com/ and after creating it, edit it to meet the requirements described in my instructions.md file

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "cypress-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@jprealini/cypress-mcp"
      ]
    }
  }
}

Use Cypress Test Generator MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Cypress Test Generator is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Cypress Test Generator as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Cypress Test Generator MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "cypress-test-generator": {
      "command": "npx",
      "args": [
        "-y",
        "@jprealini/cypress-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Cypress Test Generator MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Cypress Test Generator MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Cypress Test Generator to help me with this task?
Cypress Test Generator
Sure. I read it.
Here is what I found using Cypress Test Generator.

Frequently asked questions

What is the Cypress Test Generator MCP server used for?

Cypress Test Generator is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Cypress Test Generator MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Cypress Test Generator with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Cypress Test Generator MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Cypress Test Generator connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Cypress Test Generator MCP to TypingMind?

Cypress Test Generator runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Cypress Test Generator MCP provide in TypingMind?

Cypress Test Generator exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Cypress Test Generator MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Cypress Test Generator requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇