Gemini Prompt to Create E2E Tests
End-to-end (E2E) tests are essential to guarantee an application's overall correct functioning, yet writing them is often time-consuming and repetitive. Gemini, Google's AI model, excels at generating structured code and can dramatically accelerate the creation of complete E2E test suites. By providing the technical context of your application — tech stack, critical user journeys, and the test framework used — Gemini can produce robust test scenarios covering both main flows and edge cases. Whether you use Playwright, Cypress, or Selenium, the AI adapts to your framework's conventions to generate directly usable code. The prompt engineering approach allows you to precisely specify the desired coverage level, the selector patterns to favor, and the test data management strategy. The result: maintainable, readable tests aligned with your team's best practices, produced in a fraction of the usual time.
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 am working on a [APPLICATION_TYPE: web/mobile/desktop] application built with [TECH_STACK: e.g. React, Node.js, PostgreSQL].
E2E test framework used: [FRAMEWORK: Playwright/Cypress/Selenium]
Base URL: [URL]
Here is the user journey to test:
[DESCRIBE_THE_COMPLETE_FLOW_STEP_BY_STEP]
Generate a complete E2E test suite following these rules:
- Use resilient selectors (data-testid, ARIA roles) — never fragile CSS selectors
- Each test must be independent and idempotent
- Include test data setup and teardown
- Handle loading states and asynchronous waits explicitly
- Cover the happy path, error cases (invalid form, network timeout, 403/404), and edge cases
- Add comments explaining the business logic tested
- Use the Page Object Model pattern for reusability
- Include meaningful assertions at every key step
Structure your response as follows:
- Required Page Objects with their methods
- Configuration file and fixtures
- Test suite organized by feature
- Helper for seeding test data
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 Gemini and provides all the technical context needed to generate code tailored to your environment. The numbered rules act as quality constraints that eliminate common anti-patterns (fragile selectors, coupled tests, implicit waits). The enforced output structure forces a result organized according to the Page Object Model pattern, directly integrable into a professional codebase.
Use Cases
Variants
Expected Output
You get a complete and structured E2E test suite: Page Objects encapsulating interactions with each page, fixtures for data seeding, and test files organized by feature covering the happy path and error cases. The generated code uses resilient selectors, properly handles asynchronous operations, and includes business comments to facilitate long-term maintenance.
Frequently Asked Questions
Which E2E testing framework does Gemini handle best?
Gemini 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 native parallelization, while Cypress is better suited for frontend teams prioritizing developer experience. Always specify the framework and its version in your prompt to get up-to-date syntax and avoid deprecated APIs.
How can I ensure long-term maintainability of tests generated by Gemini?
Three key practices ensure maintainability: first, require the Page Object Model pattern in your prompt to encapsulate selectors and interactions per page. Second, enforce the use of data-testid selectors instead of style-dependent CSS selectors, which break with every visual refactoring. Third, ask Gemini to add comments explaining the business intent of each test, not just the technical action. Always review the generated code and adapt variable names and file structure to your team's conventions.
Can Gemini generate E2E tests from user stories or mockups?
Yes, Gemini can transform user stories into E2E test scenarios if you clearly articulate them in your prompt. Describe each story using the format 'As a [role], I want [action] so that [benefit]' followed by detailed acceptance criteria. For mockups, Gemini (in multimodal version) can analyze screenshots and infer the interactive elements to be tested. Combine both approaches—story + screenshot—to achieve the most comprehensive coverage.
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
Ajoutez au prompt la liste des `data-testid` existants dans votre app, sinon Gemini risque d'en inventer et vos tests échoueront. Pour Playwright, précisez si vous voulez utiliser les fixtures natives et le mode parallel. Demandez aussi un exemple de données de test réalistes pour le seeding.
📬 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