P

ChatGPT Prompt for Creating E2E Tests

End-to-end (E2E) tests are essential for ensuring an application works as a whole, but writing them is often time-consuming and repetitive. ChatGPT can significantly speed up this process by generating complete test scenarios covering critical user paths, edge cases, and required assertions. Whether you use Cypress, Playwright, Selenium, or any other framework, the AI can produce structured and maintainable tests from a simple functional description. The key is to provide a precise enough prompt to obtain realistic tests that follow best practices (stable selectors, async handling, test isolation) and integrate directly into your CI/CD pipeline. In this guide, you'll find a main optimized prompt as well as variants adapted to your expertise level, to transform your functional specifications into robust E2E test suites in seconds.

The prompt

ChatGPT

You are a senior QA engineer specialized in end-to-end testing. I will describe a feature of my web application and I want you to generate a complete E2E test suite.

Technical context:

  • Testing framework: [Cypress / Playwright / Selenium]
  • Language: [TypeScript / JavaScript]
  • Application: [BRIEF_APP_DESCRIPTION]

Feature to test:
[DESCRIBE_USER_JOURNEY]

Mandatory instructions:

  1. Use stable selectors (data-testid, ARIA roles) — never fragile CSS selectors
  2. Each test must be independent and idempotent
  3. Handle async correctly (explicit waits, no arbitrary sleeps)
  4. Cover the happy path, at least 2 error cases, and 1 edge case
  5. Add comments explaining the logic of each test block
  6. Include necessary setup and teardown (fixtures, test data, initial state)
  7. Name tests descriptively with the pattern: "should [ACTION] when [CONDITION]"

Generate the complete code, ready to be copied into a test file.

Personalize this prompt with Léa

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why it works

This prompt works because it assigns the AI a precise expert role and strictly frames the technical constraints, eliminating generic responses. By imposing concrete rules (stable selectors, test independence, async handling), it forces ChatGPT to produce code that follows best practices recognized by the QA community. The structure in distinct sections (context, feature, instructions) leverages the AI's ability to follow multi-level instructions for a directly usable result.

Expected result

You will get a complete and structured test file containing 5 to 10 test cases covering the happy path, common errors, and edge cases. The generated code will use the best practices of the chosen framework, with robust selectors, clean async handling, and explanatory comments. The result is ready to be integrated into your existing test suite with minimal adjustments.

Variants by level

FAQ

Which E2E testing framework should I specify in the prompt for best results?
ChatGPT produces excellent results with Playwright and Cypress, the two most documented frameworks in its training data. Playwright is recommended for projects requiring multi-browser support and advanced network interception, while Cypress is perfect for React/Vue applications with its simpler approach. Always specify the framework and version in your prompt to avoid outdated APIs.
How can I ensure the tests generated by ChatGPT are reliable and not flaky?
Three precautions are essential: first, explicitly ask in your prompt to use explicit expectations (waitFor, expect with retry) rather than fixed delays. Second, require stable selectors (data-testid) and not CSS selectors that may break with minor design changes. Finally, always review the generated tests and run them multiple times consecutively to detect flaky behavior before integrating them into your CI.
Can I use ChatGPT to generate E2E tests from user stories or mockups?
Yes, it's even one of the most efficient use cases. Copy the text of your user story directly into the prompt specifying acceptance criteria. For mockups, describe the visible interface elements and expected interactions. ChatGPT will transform these functional specifications into concrete test scenarios. For complex mockups, you can use GPT-4 Vision by uploading a screenshot and asking to generate the corresponding tests.

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 4800+ 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

ChatGPT Prompt for Creating Flashcards

Flashcards are one of the most effective learning methods, based on the principle of spaced repetition and active recall. Yet, creating high-quality flashcards manually requires considerable time: formulating questions, synthesizing answers, structuring information by difficulty level. That's precisely where ChatGPT becomes a valuable ally.

ChatGPT Prompt for Creating Infographics

Infographics have become an essential communication tool to synthesize complex data into impactful visuals. Whether you are a marketer, teacher, journalist or entrepreneur, the ability to create clear and engaging infographics is a major asset. ChatGPT revolutionizes this process by allowing you to structure, write and conceptualize your infographics without graphic design skills. With well-crafted prompts, you can get a complete visual architecture: information hierarchy, key data selection, catchy titles, captions and layout suggestions. ChatGPT excels particularly in transforming raw data into coherent visual stories, identifying the most striking statistics and proposing narrative structures adapted to your audience. This guide provides optimized prompts for each step of infographic creation, from initial brainstorming to final writing of texts that will accompany your visuals. You will discover how to leverage artificial intelligence to produce professional infographics that capture attention and convey your message with impact.

ChatGPT Prompt for Creating UI Design

User interface (UI) design is an area where ChatGPT can become a valuable assistant, even if it doesn't generate visual mockups directly.

ChatGPT Prompt for Creating YouTube Thumbnails

YouTube thumbnails are the first visual element your viewers see before clicking on a video. An eye-catching thumbnail can make the difference between an ignored video and viral content.

ChatGPT Prompt for Data Analysis

Data analysis has become an indispensable strategic lever for businesses and professionals. Yet extracting relevant insights from raw datasets remains a technical challenge that usually requires skills in statistics, programming, or specialized tools like advanced Excel, Python, or R. ChatGPT radically transforms this approach by allowing anyone to analyze complex data through natural language instructions.

ChatGPT Prompt for Evaluating Skills

Skills assessment is a central issue for recruiters, managers, and trainers. Traditionally time-consuming and subjective, this process can be significantly improved with ChatGPT.

Go further

Get new prompts every week

Join our newsletter.