Theory
AI has changed testing at every level. For unit tests, tools like GitHub Copilot can generate tests for a whole class or file in seconds, then automatically run them and fix failures. For end-to-end tests, Playwright MCP lets an AI agent connect to a live browser session and interact with your app the same way a human would: clicking, typing, reading the DOM. The agent can generate test scripts from natural language, fix broken selectors when the UI changes, and even verify that a feature it just built actually works in the browser.
The TDD loop with AI is simple: you describe a behavior, the AI writes a failing test, then writes the code to make it pass, then runs it to confirm. Tools like GitHub Copilot Testing and BMAD TEA go further, adding risk-based prioritization so you know which tests matter most before a release. TEA can trace requirements to test coverage, assess non-functional risks, and give a clear go/no-go decision. The result is a testing workflow where AI handles the repetitive parts and you stay focused on what to test and why.
Practice
Run this in a repository you already know, not a toy project. The point is to feel where the practice helps and where it gets in the way on code that has history.
Pick any small web app you have locally (or clone a simple one). Then:
- Install the Playwright VS Code extension and run
npm init playwright@latestto scaffold your test setup. - Add the Playwright MCP server to your AI agent (Claude, Copilot, or Cursor). With GitHub Copilot in VS Code it is already built in.
- Open a chat with your AI agent and write: "Open my app at localhost:3000, explore the main user flow, and generate Playwright tests for the most critical path."
- Let the agent browse your app, inspect the DOM, and write the test file.
- Run the generated tests with
npx playwright test. Check the HTML report withnpx playwright show-report. - If any test fails, open the Trace Viewer, click "Copy as Prompt", and ask the AI to fix the issue.
By the end you should have at least one working E2E test generated almost entirely by an AI agent, and you will have seen the full loop: describe intent, AI browses, AI writes tests, AI fixes failures.