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
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
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.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Pour des tests multi-navigateurs, ajoutez "Génère aussi une configuration parallélisée sur [BrowserStack/Sauce Labs]" après le contexte technique. Cela forcera le prompt à produire le fichier de config associé.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Sora Prompt for Creating E2E Tests
End-to-end (E2E) tests are essential for ensuring application reliability, but writing them remains time-consuming and repetitive. Sora, thanks to its advanced generation capabilities, makes it possible to automate the creation of complete E2E test scenarios in seconds. By formulating a precise prompt describing user journeys, expected interactions, and validation criteria, you obtain structured test suites covering nominal cases as well as edge cases. The prompt engineering approach applied to Sora transforms how QA and development teams approach test coverage. Instead of starting from a blank page, you describe the expected behavior of your application in natural language, and Sora generates the corresponding test code with appropriate assertions. This method significantly reduces the time needed to set up an E2E suite while maintaining a professional quality level. Whether you use Playwright, Cypress, or Selenium, the prompts presented here adapt to your technical stack and the complexity of your application.
Implement rate limiting
Protect APIs from abuse
GitHub Copilot Prompt for Creating a REST API
GitHub Copilot has become an essential assistant for developers looking to accelerate the creation of REST APIs. Thanks to its direct integration into the code editor, it understands the context of your project and generates structured code in real time. Whether you work with Node.js and Express, Python and FastAPI, or Java and Spring Boot, Copilot adapts to your tech stack to produce endpoints conforming to REST conventions. The main challenge lies in formulating the prompt: a well-structured prompt yields a complete API with data validation, error handling, authentication, and documentation. A vague prompt, on the other hand, will produce generic code requiring many adjustments. In this guide, we offer an optimized prompt that fully leverages GitHub Copilot's capabilities to generate a professional, testable, production-ready REST API. You will also discover variants adapted to your experience level as well as practical tips to get the most out of this tool on a daily basis.
Implement CSP with nonces
Prevent XSS with strict CSP