Claude Prompt for Creating E2E Tests
End-to-end (E2E) tests are essential to ensure your application works correctly from the end user's perspective. However, writing them is often time-consuming and repetitive: simulating complete user journeys, handling selectors, async waits, and UI state assertions. Claude excels at this task by generating structured, maintainable E2E tests covering both happy paths and edge cases. By providing context about your application — tech stack, test framework, page structure — Claude produces ready-to-run test suites for Playwright, Cypress, or other tools. It understands best practices like data-testid usage, the Page Object Model pattern, and loading state management. Whether starting from scratch or supplementing existing coverage, Claude transforms a functional description into robust tests in seconds, letting you focus on business logic rather than technical plumbing.
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. Generate a complete E2E test suite for the following feature:
Application: [Describe your application and its tech stack]
Test framework: [Playwright / Cypress / other]
Feature to test: [Describe the user journey]
Base URL: [Local or staging URL]
For each test, apply these rules:
- Use robust selectors (data-testid preferred, then ARIA roles, never fragile CSS selectors)
- Implement the Page Object Model pattern for reusability
- Explicitly handle async expectations (wait for visible elements before interacting)
- Cover the happy path, error cases (invalid form, network timeout), and edge cases (empty fields, special characters)
- Add comments explaining the business logic being tested
- Isolate each test (no test interdependence, clean setup/teardown)
- Name each test with the format: "should [expected action] when [condition]"
Generate complete code with imports, configuration, page objects, and test files.
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 Claude a precise expert role (senior QA engineer), activating specialized testing knowledge. The seven numbered rules act as structural constraints that eliminate common anti-patterns (fragile selectors, coupled tests, weak assertions). By explicitly requesting technical context (framework, stack, URL), the prompt forces a response tailored to the real environment rather than generic code.
Use Cases
Variants
Expected Output
You will receive a complete and organized E2E test suite: Page Object files encapsulating interactions with each page, test files covering happy path and error cases, and a basic configuration for the chosen framework. Each test is descriptively named, isolated from others, and accompanied by comments explaining the business scenario being verified.
Frequently Asked Questions
Which E2E testing framework does Claude handle best?
Claude excels with all major frameworks — Playwright, Cypress, Selenium, and Puppeteer — but produces the best results with Playwright and Cypress due to the wealth of training data. Playwright is recommended for modern projects because Claude naturally generates code using its advanced features: auto-waiting, ARIA role selectors, and multi-browser execution. Always specify your framework in the prompt to get idiomatic code rather than generic output.
How can I get Claude to generate tests that don’t break with every UI change?
The key is to instruct Claude on your selector strategy within the prompt. Explicitly ask it to use data-testid attributes instead of CSS or XPath selectors tied to the DOM structure. You can also provide your existing naming convention (e.g., data-testid="login-submit-btn") so it stays consistent. The Page Object Model pattern, requested in the intermediate and advanced variants, centralizes selectors in one place, preventing cascading changes when the interface evolves.
Can Claude generate E2E tests from a user story or mockup?
Yes, and that’s one of its strengths. You can paste a Jira user story, a functional specification, or even describe a mockup in natural language, and Claude will deduce the paths to test. For visual mockups, leverage Claude’s multimodal capability by attaching a screenshot: it will identify interactive elements, forms, and navigation flows to generate corresponding tests. The more precise your description (form fields, expected error messages, redirects), the more closely the generated tests will match the intended behavior.
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 une configuration de fixtures (ex. avec `test.use` dans Playwright) pour injecter des données mockées API, évitant ainsi les dépendances à un backend instable tout en gardant les tests isolés et reproductibles.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Distributed Tracing with OpenTelemetry
Implement distributed tracing
Advanced Scheduling Strategy
Optimize pod placement
DALL-E Prompt to Generate a Database Schema
DALL-E, OpenAI's image generation model, can be creatively used to produce visual database schemas. Whether you are a developer, software architect, or student, visualizing a database structure as an entity-relationship diagram is essential for understanding links between tables, primary keys, and relationships. Rather than using technical tools like dbdiagram.io or Lucidchart, DALL-E allows you to quickly generate a clear and aesthetic visual of a relational schema, ideal for presentations, educational documents, or brainstorming sessions. The main challenge lies in formulating the prompt: you need to guide the model precisely to obtain a readable diagram, with explicit table names, well-defined columns, and relationships clearly represented by lines and cardinalities. In this guide, you will discover an optimized prompt to generate a professional database schema with DALL-E, as well as variants adapted to your level of expertise and the complexity of your project.
Gemini Prompt for Creating a Chatbot
Gemini, Google's artificial intelligence model, offers remarkable capabilities for designing high-performance chatbots tailored to your needs. Whether you want to create a customer assistant for your e-commerce site, a technical support bot or a conversational companion, Gemini excels at understanding natural language nuances and generating contextual responses. Thanks to its extended context window and multimodal capability, Gemini enables building chatbots that can process text, images and even documents. The main challenge lies in the quality of the initial prompt that will define your chatbot's personality, tone, limits and skills. A well-structured prompt transforms Gemini into a true conversational architect, capable of generating the code, dialogue flows and business logic needed. In this guide, we offer optimized prompts to get the most out of Gemini when creating chatbots, from rapid prototyping to production deployment with error handling and advanced customization.