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: you need to simulate complete user journeys, manage selectors, async waits, and UI state assertions. Claude excels at this task by generating structured, maintainable E2E tests covering both nominal and edge cases. By providing your application context — tech stack, test framework, page structure — Claude produces test suites ready to run with Playwright, Cypress, or any other tool. It understands best practices like using data-testid, the Page Object Model pattern, and handling loading states. Whether starting from scratch or extending existing coverage, Claude transforms a functional description into robust tests in seconds, letting you focus on business logic rather than technical plumbing.
The prompt
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 first, then ARIA roles, never fragile CSS selectors)
- Implement the Page Object Model pattern for reusability
- Explicitly handle async waits (wait for elements to be visible before interacting)
- Cover the happy path, error cases (invalid form, network timeout), and edge cases (empty fields, special characters)
- Add comments explaining the tested business logic
- Isolate each test (no test dependencies, clean setup/teardown)
- Name each test with the format: "should [expected action] when [condition]"
Generate the complete code with imports, configuration, page objects, and test files.
Personalize this prompt with Léa
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why it works
This prompt works because it assigns Claude a precise expert role (senior QA engineer), activating its specialized testing knowledge. The seven numbered rules act as structuring 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.
Expected result
Variants by level
FAQ
Which E2E test framework does Claude handle best?
How can I make Claude generate tests that don't break with every UI change?
Can Claude generate E2E tests from a user story or a mockup?
Related prompts
How to use this prompt
- Copy the prompt with the button above.
- Paste it into ChatGPT, Claude or your favorite AI assistant.
- Replace the bracketed variables with your details, then refine the result.
About Prompt Guide
Prompt Guide is a free library of 4800+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.
More prompts to explore
Claude Prompt for Creating Images
Claude, Anthropic's AI assistant, now has image generation capabilities that allow you to create visuals directly in the conversation.
Claude Prompt for Drafting a Contract
Drafting contracts is a demanding task that requires legal precision, editorial clarity, and rigorous structure. Claude, Anthropic's AI assistant, can effectively accompany you in this process by generating professional contract drafts tailored to your specific needs.
Claude Prompt for Drafting Terms of Service
Drafting Terms of Service (ToS) is a mandatory legal step for any website, mobile app, or online service. These documents...
Claude Prompt for Extracting Data Insights
Extracting insights from raw data is one of Claude's most powerful use cases. Whether you work with CSV exports, reports
Claude Prompt for Generating Advertising Visuals
Anthropic's Claude revolutionizes advertising visual creation by enabling marketers, designers, and entrepreneurs to generate detailed visual concepts, complete creative briefs, and image descriptions ready for production.
Claude Prompt for Planning a Product Launch
The launch of a product is a pivotal moment that can determine the success or failure of an offer in the market. Between defining positioning, coordinating marketing teams, planning distribution channels and managing the timeline, there are many variables to orchestrate.
Go further
Get new prompts every week
Join our newsletter.