P

GitHub Copilot Prompt for Creating E2E Tests

End-to-end (E2E) tests are essential for validating the overall functionality of an application, but writing them is often time-consuming and repetitive. GitHub Copilot, integrated directly into your code editor, can significantly speed up this process by generating complete test scenarios from natural language descriptions. Whether you use Playwright, Cypress, or Selenium, Copilot understands your project's context—components, routes, selectors—to produce realistic and maintainable tests. The challenge is to formulate precise enough prompts to obtain tests that cover critical user paths, handle wait states, and assertions robustly, while respecting best practices of your test framework. In this guide, you'll find one main optimized prompt as well as variants adapted to your experience level to get the most out of GitHub Copilot in creating your E2E tests.

The prompt

GitHub Copilot

Generate a suite of end-to-end tests with Playwright in TypeScript for the following user journey: [DESCRIBE_THE_JOURNEY, e.g., registration, login, add to cart, payment]. For each step of the journey, create an independent test in a describe block. Use the following best practices: accessible selectors (getByRole, getByText, getByTestId), explicit expectations with expect and toBeVisible/toHaveText, handling loading states with waitForLoadState, fixtures for reusable authentication, and the Page Object Model to encapsulate interactions with each page. Add assertions on URLs, displayed content, and visual states. Include a playwright.config.ts configuration file with baseURL, retries, and HTML reporter. Comment each section to explain the test logic.

Personalize this prompt with Léa

Answer 3 questions and Léa tailors the prompt to your situation.

Why it works

This prompt works because it specifies the framework (Playwright), the language (TypeScript), and the concrete user journey, eliminating ambiguity for Copilot. It imposes precise architectural patterns like the Page Object Model and accessible selectors, guiding generation towards maintainable code. Finally, it explicitly requests configuration, assertions, and comments, producing a complete and ready-to-execute deliverable.

Expected result

Copilot generates a structured E2E test suite with a Playwright configuration file, Page Object classes for each page of the journey, and tests organized by describe/test covering each step. Each test includes robust selectors, explicit DOM and URL assertions, and handling of asynchronous states. The code is commented and directly executable with npx playwright test.

Variants by level

FAQ

How does GitHub Copilot handle dynamic selectors in E2E tests?
Copilot analyzes your project's context to suggest the most stable selectors. If you have data-testid attributes in your source code, it will prioritize them automatically. For best results, specify the desired selector type in your prompt (getByRole, getByTestId, getByText) and Copilot will comply. Avoid fragile CSS selectors based on classes by explicitly mentioning this in your instruction.
Can Copilot generate E2E tests for Cypress or Selenium in addition to Playwright?
Yes, GitHub Copilot supports all major E2E test frameworks. Simply replace 'Playwright' with 'Cypress' or 'Selenium WebDriver' in your prompt. Copilot will automatically adapt the syntax: cy.visit() and cy.get() for Cypress, driver.findElement() and driver.get() for Selenium. For best results, open an existing test file of the target framework before formulating your prompt so that Copilot picks up the context.
How to integrate Copilot-generated E2E tests into a CI/CD pipeline?
Tests generated by Copilot are directly compatible with CI/CD pipelines. Ask in your prompt to include the CI configuration (GitHub Actions, GitLab CI) in addition to the tests. Copilot can generate a complete YAML workflow with dependency installation, launching a development server, running tests with retries, and publishing reports and artifacts (screenshots, traces). Make sure to ask for environment variable handling via CI secrets for credentials.

Related prompts

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More prompts to explore

GitHub Copilot Prompt for Creating Illustrations

GitHub Copilot, initially designed as a programming assistant, proves to be a remarkable tool for generating code to create illustrations

GitHub Copilot Prompt for Creating Infographics

GitHub Copilot, the AI-powered coding assistant, proves to be a formidable ally for generating SVG, HTML, and CSS code to create infographics.

GitHub Copilot Prompt for Creating Mockups

GitHub Copilot, GitHub's AI-powered code assistant, proves to be a formidable tool for creating mockups directly in your code editor.

GitHub Copilot Prompt for Debugging Code

Debugging is one of the most time-consuming tasks in software development. GitHub Copilot, integrated directly into your code editor, can significantly

GitHub Copilot Prompt for Extracting Data Insights

GitHub Copilot, the AI coding assistant integrated into IDEs, is a powerful ally for extracting insights from raw data. Whether you are working with CSV files, SQL databases, or pandas DataFrames, Copilot can quickly generate exploratory analysis, visualization, and statistical summary code. The main challenge lies in crafting the prompt: a well-structured prompt allows Copilot to produce relevant analysis code on the first try, without unnecessary iterations. By clearly specifying the data format, the metrics you're looking for, and the type of visualization desired, you turn Copilot into a true data analyst capable of detecting trends, anomalies, and hidden correlations in your datasets. This page offers an optimized main prompt as well as variants tailored to your skill level, to get the most out of GitHub Copilot in your data analysis workflows.

GitHub Copilot Prompt for Generating a Database Schema

GitHub Copilot radically transforms how developers design their databases. Instead of starting from a blank page and manually writing every CREATE TABLE statement, you can now describe your business domain in natural language and get a complete schema in seconds.

Go further

Get new prompts every week

Join our newsletter.