with-agents

Beyond Code Coverage: Functionality Testing with Playwright MCP

Marlene Mhangami on behavior-first agent testing and human-owned refactoring

Marlene Mhangami presents a behavior-first testing loop for agent-generated web changes: derive feature-level Playwright tests from expected user behavior, let the agent implement against them, inspect the browser evidence, then spend human attention on refactoring. A prepared GitHub Copilot CLI and Playwright MCP demo exercises search and filtering in a sample app. It illustrates the workflow without comparing defect detection or maintenance cost with other approaches.

AI Engineer

Marlene Mhangami presents a behavior-first testing loop for agent-generated web changes. She proposes turning each feature request into a failing Playwright browser test before implementation, letting the agent write code until that test passes, and spending most human attention on refactoring the result.

Key Points Covered

  • More generated code does not establish more productive delivery: Mhangami uses GitHub activity figures and a cited developer study to motivate the talk. Citing the study, she argues that AI amplifies gains in clean codebases and amplifies entropy (lower code quality and more rework) where its use goes unchecked. To keep a codebase clean, she points to test coverage, type coverage, documentation, and modularity. The talk does not present the study methodology or independently validate the extrapolated commit figures 00:15–04:12(opens in a new tab).
  • Behavior should survive internal refactoring: Tests coupled to method names and other implementation details can fail even when user-visible behavior remains correct. Mhangami recommends targeting stable contracts and final outcomes instead 06:07–08:09(opens in a new tab).
  • Tests can copy the implementation's mistakes: If an agent derives expected results from the code it just wrote, its tests may confirm what that code does rather than what the feature should do. A green suite and high coverage can therefore coexist with incorrect application behavior 07:12–08:09(opens in a new tab).
  • A feature request, not a new method, should trigger the first test: Red-green-refactor means writing a failing test (red), making it pass (green), then cleaning up the code. With unit tests, adding a method to a class typically prompted a new test. In Mhangami's version, the expected behavior of a requested feature becomes a failing Playwright test before implementation 09:12–10:04(opens in a new tab), 11:44–13:51(opens in a new tab).
  • Playwright lets agents check behavior in a real browser: Playwright is Microsoft's open-source end-to-end testing framework. It simulates user interactions in a visible (headed) or background (headless) browser. Mhangami names three ways to connect a coding agent to it: the Playwright MCP server, the Playwright CLI, and Playwright agents, which install planner, generator, and healer instruction files that plan, write, and fix tests 08:09–10:54(opens in a new tab).
  • The demo checks search and filtering through a browser: Mhangami asks GitHub Copilot CLI to inspect a Tailspin Toys codebase and write failing feature tests before implementation. She then switches to a prepared session showing the implemented feature and browser interactions for text search, category filters, and price filters. The recording illustrates the workflow rather than showing every generation step live or comparing defect detection with other testing approaches 11:44–15:52(opens in a new tab).
  • Refactoring becomes the main human job: Mhangami expects agents to make the red and green phases fast. Developers should then spend most of their time inspecting and improving the code the agent generated 09:12–10:04(opens in a new tab), 15:52–16:56(opens in a new tab).
  • Make the execution evidence reviewable: She recommends attaching Playwright screenshots to pull requests and using headless execution when appropriate. She also recommends committing before asking an agent to repair failures and keeping each test focused on one feature 15:52–16:56(opens in a new tab).
  • The demonstrated scope is browser functionality: In the Q&A, Mhangami suggests direct API tests when Playwright is unnecessary. She recommends Playwright agents for state-heavy cases and confirms that the presented approach is browser-based 17:57–18:46(opens in a new tab).

Full video: https://www.youtube.com/watch?v=FWEInOtngmM(opens in a new tab)

Search

Search field guides and resources across the site.

    Keyboard shortcuts

    Press ? to open this guide (usually Shift + /). Close it before using other site shortcuts.

    Show keyboard shortcuts
    ?
    Search site
    Ctrl + K
    Close the current dialog or menu
    Esc

    Site shortcuts are ignored while typing. Browser and extension shortcuts may take priority.