P
💻DeveloppementIntermediateGemini

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:

  1. Use resilient selectors (data-testid, ARIA roles) — never fragile CSS selectors
  2. Each test must be independent and idempotent
  3. Include test data setup and teardown
  4. Handle loading states and asynchronous waits explicitly
  5. Cover the happy path, error cases (invalid form, network timeout, 403/404), and edge cases
  6. Add comments explaining the business logic tested
  7. Use the Page Object Model pattern for reusability
  8. 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

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

Create E2E Tests

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 Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateAll AIs

Namespace and Quota Management

Manage a multi-tenant cluster

0108
💻DeveloppementBeginnerAll AIs

Artifact Retention Policy

Optimize artifact storage costs

097
💻DeveloppementAdvancedAll AIs

Build a virtualized list

Handle massive data lists

0142
💻DeveloppementIntermediateChatGPT

Prompt ChatGPT to Generate SQL Queries

Generating SQL queries is an essential skill for any developer, data analyst, or database administrator. However, writing complex queries involving multiple joins, nested subqueries, or aggregate functions can be time-consuming and error-prone. ChatGPT transforms this practice radically by allowing you to describe your needs in natural language to obtain optimized and functional SQL queries in seconds. Whether you work with MySQL, PostgreSQL, SQL Server, or SQLite, the AI adapts to the specific syntax of your database management system. By providing your table schema and a clear description of what you want, you can generate perfectly structured SELECT, INSERT, UPDATE, or DELETE queries. ChatGPT also excels at line-by-line explanations of generated queries, making it a valuable learning tool for beginners and professionals alike who wish to explore advanced SQL features like CTEs, window functions, or recursive queries.

0118