Skip to main content

Use Case 9: "I need end-to-end tests"

Scenario: Your QA team wants automated browser tests for critical user flows.

Time: ~15 minutes

Copilot Features: MCP Playwright

Your Challenge: Generate and run Playwright tests using MCP integration.

Playwright is a popular end-to-end testing framework for web applications. GitHub Copilot can integrate with Playwright via the Model Context Protocol (MCP) to generate and run tests based on natural language prompts.

Step 1: Start Playwright MCP​

  1. In the GitHub Copilot app, open Customize → MCP servers and enable the Playwright server for the session.
  2. If you are using VS Code instead, open the Command Palette (Cmd/Ctrl + Shift + P), select MCP: List Servers, select the Playwright server, and click Start Server.

Step 2: Generate Test Scenarios​

This requires the shopping cart from Use Case 1. Start the session from the merged default branch or from the cart pull request branch; do not start from a branch that lacks the cart changes.

  1. Start a focused session in Interactive mode and leave the model on Auto. In VS Code, use Agent mode.
  2. Prompt:
    Create a Playwright e2e feature file testing:
    1. User adds two products to cart
    2. Verifies cart badge shows "2"
    3. Opens cart page
    4. Verifies subtotal is correct
    5. Removes one item
    6. Verifies badge updates to "1"

    Consult playwright config for the appropriate directories and setup.
  3. Review the files created (feature file in Gherkin format and E2E test implementation)

Step 3: Run Tests (Local Only)​

  1. Prompt:
    Run these tests in headless mode and show me results
  2. You may be prompted to install Chromium dependencies.
  3. Copilot executes the tests using MCP and discusses the results in the session.

What You Learned​

✅ MCP Integration - Extend Copilot with external tools
✅ Browser Automation - Generate E2E tests from natural language
✅ BDD Workflows - Readable, maintainable test scenarios in Gherkin

Time Investment: 15 minutes
Value: E2E tests without learning Playwright syntax

Next Steps​

Continue to Spec-Driven Development to learn how to build features from specifications.