I "accidently" turned my e2e tests into MCP tools
Hey guys!
I've been pimping playwright for a while - chasing my obsession of building a tool that lets me create e2e tests quickly while enforcing best practices like proper use of fixtures, semantic POM etc.
I'm pretty far already - UI-based e2e test recording works, giving me proper test steps, POM, UI and API tests - but my current project at work gave me an idea that sent me on a side quest.
tldr;
Check the video:
- I record our dashboard creation flow using my tool in Cursor
- Cursor writes POM, fixtures, e2e test, WebMCP tool definition, wiring
- I ask the AI-Assistant to create a new Dashboard for me
- The assistant creates the dashboard using the newly recorded flow
I've been working on creating our in-app AI assistant during my day job. One of our main goals is helping our users with onboarding: explaining to them how certain features work and where they can find stuff on the UI.
I wanted to take it a step further, since imo showing is better than telling. Certain UI Assistant libraries (we're using CoplikotKit) allow calling FE tools and MCPs. My idea was to expose our main user flow as FE tools to our assistant, so they can do things on the user's behalf - or show them when prompted.
I modified my tool to not only generate POM and e2e tests, but also FE tool and MCP definitions from the same, single source of truth.
So now from one recording, I'm able to generate:
- A single flow.spec.ts file that can execute the same flow using 3 modes:
- ui-based e2e test
- API e2e test
- FE tool test (via WebMCP bridge)
- WebMCP tools for any AI assistant use (claude, codex etc)
- Wiring WebMCP tools into our in-app CopilotKit assistant
It's still super early, but I've always been fascinated by the idea of having a single source of truth for features, exposing them to the world through different interfaces (UI, API, MCP, whatever you want).
Next things I probably want to do:
- define API-based WebMCP tools using the same approach, so the user can choose if they want the UI showcase or the fast track.
- Zoom out a little, and consider what this means from a security perspective :D
What's your opinion? Have you tried something similar on your own?
Is this something you would find useful or exciting, either from the testing or user-facing /UX perspective?