Playwright MCP not supported by Curosr, cannot use new playwright agents properly

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Cursor Playwright MCP Generator Bug Report

Date: October 31, 2025
Project: E2E Test Suite
Cursor/Playwright Versions:

  • @playwright/test: 1.56.0
  • Node.js: v18+

Issue Description

The Cursor-integrated Playwright MCP generator tools (planner_setup_page, generator_setup_page, test_list) consistently fail with the error:

Error: Playwright Test did not expect test() to be called here.
Most common reasons include:
- You are calling test() in a configuration file.
- You are calling test() in a file that is imported by the configuration file.
- You have two different versions of @playwright/test.

at seed.spec.ts:3

Root Cause

The Cursor MCP generator tools appear to be importing/loading test files directly (similar to require('./tests/seed.spec.ts')) rather than running them through Playwright’s test runner. This causes Playwright to throw an error because the test() function can only be called within the context of Playwright’s test runner, not during direct module imports.

Expected Behavior

The MCP generator tools should be able to:

  1. Load and execute seed files to set up the browser state
  2. List all tests in the project
  3. Generate new tests based on user interactions

Actual Behavior

All MCP generator tools fail to load any test files, making the generator completely non-functional in this project.

Technical Details

The error originates from Playwright’s internal test loading mechanism:

at TestTypeImpl._currentSuite (node_modules\playwright\lib\common\testType.js:74:13)
at TestTypeImpl._createTest (node_modules\playwright\lib\common\testType.js:87:24)
at node_modules\playwright\lib\transform\transform.js:275:12

This suggests the test file is being require()'d or import()'ed directly, which triggers the tes

Steps to Reproduce

Reproduction Steps

  1. Create a minimal seed file tests/seed.spec.ts:

    import { test } from '@playwright/test'
    
    test('seed', async ({ page }) => {
        await page.goto('/')
    })
    
  2. Attempt to use any MCP generator tool:

    mcp_playwright-test_planner_setup_page
    OR
    mcp_playwright-test_generator_setup_page
    OR
    mcp_playwright-test_test_list
    
  3. Error occurs immediately when the tool tries to load the seed file or any test file

Verification Steps Taken

:white_check_mark: Confirmed only one version of @playwright/test exists (npm ls @playwright/test)
:white_check_mark: Verified seed file works when run directly: npx playwright test tests/seed.spec.ts --list (exits 0)
:white_check_mark: Checked playwright.config.ts doesn’t import test files
:white_check_mark: Checked test-base.ts doesn’t import seed file
:white_check_mark: Tried multiple seed file formats (with/without test-base, empty file, test.describe, etc.)
:white_check_mark: Created minimal playwright config without custom reporters
:white_check_mark: Installed/uninstalled @playwright/mcp package

Expected Behavior

t registration code outside of the runner context.

Workaround

Use Playwright’s built-in codegen tool and manually integrate the generated code:

npx playwright codegen http://your-app-url

Then manually adapt the generated code to match the project’s test structure and patterns.

Request

Please investigate how Cursor’s MCP generator tools load test files and ensure they use Playwright’s test runner context rather than direct imports.

Project Context

  • Project uses custom test fixtures via test-base.ts
  • Tests extend base Playwright test with custom fixtures
  • Complex test infrastructure with custom reporters
  • All tests work correctly when run via npx playwright test

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.7.54 (system setup)
VSCode Version: 1.99.3
Commit: 5c17eb2968a37f66bc6662f48d6356a100b67be0
Date: 2025-10-21T19:07:38.476Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.22621

For AI issues: which model did you use?

Claude sonnet 4.5

Does this stop you from using Cursor

No - Cursor works, but with this issue