Prompt ChatGPT to Create E2E Tests
End-to-end (E2E) tests are essential to ensure 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 necessary assertions. Whether you use Cypress, Playwright, Selenium, or any other framework, AI can produce structured and maintainable tests from a simple functional description. The challenge is to provide a sufficiently precise 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 an optimized main prompt along with variants adapted to your expertise level, to turn your functional specifications into robust E2E test suites in seconds.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
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:
- Test framework: [CYPRESS / PLAYWRIGHT / SELENIUM]
- Language: [TYPESCRIPT / JAVASCRIPT]
- Application: [brief description of the app]
Feature to test:
[Describe the user journey here]
Mandatory instructions:
- Use stable selectors (data-testid, ARIA roles) — never fragile CSS selectors
- Each test must be independent and idempotent
- Handle async properly (explicit waits, no arbitrary sleeps)
- Cover the happy path, at least 2 error cases, and 1 edge case
- Add comments explaining the logic of each test block
- Include necessary setup and teardown (fixtures, test data, initial state)
- Name tests descriptively with the pattern: "should [action] when [condition]"
Generate complete code, ready to be copied into a test file.
Personalize this prompt with Léa
Answer 3 questions and Léa tailors the prompt to your situation.
Why this prompt works
This prompt works because it assigns a precise expert role to the AI and strictly frames technical constraints, eliminating generic responses. By imposing concrete rules (stable selectors, test independence, async handling), it forces ChatGPT to produce code that adheres to best practices recognized by the QA community. The structured sections (context, feature, instructions) leverage the AI's ability to follow multi-level instructions for a directly usable result.
Use Cases
Variants
Expected Output
You'll 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 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.
Frequently Asked Questions
Which E2E testing framework should I specify in my prompt to get the best results?
ChatGPT delivers excellent results with Playwright and Cypress, the two most well-documented frameworks in its training data. Playwright is recommended for projects requiring cross-browser support and advanced network interception, while Cypress is a great fit for React/Vue applications with its simpler approach. Always specify the framework and version in your prompt to avoid deprecated APIs.
How can I ensure that the tests generated by ChatGPT are reliable and not flaky?
Three key precautions are essential: first, explicitly request in your prompt the use of explicit waits (waitFor, expect with retry) rather than fixed delays. Second, require stable selectors (data-testid) and not CSS selectors that can break with the slightest design change. Finally, always review the generated tests and run them multiple times in succession to detect intermittent behaviors before integrating them into your CI.
Can I use ChatGPT to generate E2E tests from user stories or mockups?
Yes, this is actually one of the most effective use cases. Paste your user story text directly into the prompt while specifying the acceptance criteria. For mockups, describe the visible interface elements and the 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 it to generate the corresponding tests.
Learn more
Check the full skill on Prompt Guide to master this technique from A to Z.
View on Prompt Guide📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Similar Prompts
Generate Mocks and Fixtures for Your Automated Tests
A prompt to automatically generate realistic mocks, stubs and data fixtures adapted to your test framework and use cases.
Automatically Generate Unit Tests with AI
Automatically generate an exhaustive unit test suite covering nominal cases, edge cases, and error cases for any source code.
Create a Python Automation Script
Create a professional Python automation script with CLI configuration, structured logging, error handling, and tests.
Analyze and Optimize Algorithmic Complexity
Analyze the Big O complexity of your algorithms and optimize them with appropriate data structures and more efficient algorithms.