Prompt to Write End-to-End Tests with Playwright
Generates a complete Playwright end-to-end test suite with Page Object Model, nominal and error scenarios, fixtures and optimized configuration.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un ingénieur QA senior spécialisé en tests end-to-end avec Playwright. Génère une suite de tests E2E complète pour l'application suivante :
- Type d'application : [TYPE_APPLICATION (ex: e-commerce, SaaS, blog, application bancaire)]
- Stack technique : [STACK_TECHNIQUE (ex: Next.js + API REST, Vue.js + GraphQL, React + Node.js)]
- Fonctionnalités à tester : [FONCTIONNALITES (ex: inscription, connexion, ajout au panier, paiement, tableau de bord)]
- URL de base : [URL_BASE (ex: http://localhost:3000)]
Pour chaque fonctionnalité, génère :
-
Un fichier de test Playwright (.spec.ts) avec :
- Des descriptions de test claires en français
- L'utilisation du Page Object Model pour isoler les sélecteurs
- Des assertions explicites avec
expect - La gestion des états (beforeEach, afterEach) pour l'isolation des tests
- Des data-testid pour les sélecteurs (pas de sélecteurs CSS fragiles)
-
Les scénarios suivants pour chaque fonctionnalité :
- Le parcours nominal (happy path)
- Au moins 2 cas d'erreur (champs vides, données invalides, timeout réseau)
- Un test de régression visuelle si pertinent
-
Un fichier de fixtures (test-data.ts) contenant les données de test réutilisables.
-
La configuration playwright.config.ts adaptée avec :
- Les navigateurs cibles (Chromium, Firefox, WebKit)
- Les timeouts appropriés
- Le base URL configuré
- Le reporter HTML activé
Respecte ces bonnes pratiques :
- Chaque test doit être indépendant et idempotent
- Utilise
test.describepour regrouper les tests par fonctionnalité - Privilégie
locatoravec des rôles ARIA ou data-testid - Ajoute des commentaires expliquant la logique métier testée
- Inclus des
await page.waitForLoadState()aux endroits critiques - Gère l'authentification via storageState pour éviter de se reconnecter à chaque test
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
<p>This prompt lets you quickly generate a professional end-to-end test suite with Playwright. By specifying the <strong>application type</strong> and <strong>tech stack</strong>, the AI adapts tests to your project's real context: appropriate selectors, framework-specific state management, and relevant business scenarios.</p><p>The prompt enforces the use of <strong>Page Object Model</strong>, an essential pattern for maintaining readable and scalable tests. Selectors based on <strong>data-testid</strong> and ARIA roles ensure robust tests that don't break with the slightest CSS change. The systematic inclusion of error cases and visual regression tests ensures comprehensive coverage.</p><p>To get the most from this prompt:</p><ul><li>Be specific about the <strong>features to test</strong> — list critical user journeys rather than generic pages</li><li>Mention <strong>external dependencies</strong> (third-party API, database) so the AI proposes appropriate network mocks or interceptors</li><li>Iterate by requesting performance or accessibility tests once the base is in place</li></ul>
Use Cases
Expected Output
A suite of ready-to-use TypeScript files including Playwright tests organized by feature, corresponding Page Objects, a fixtures file with test data, and an optimized Playwright configuration for multi-browser execution.
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 un rendu plus robuste, demandez à Playwright de lancer l’application via `webServer` dans `playwright.config.ts` (commande npm, port, `reuseExistingServer`), et d’utiliser les fixtures natives (`test.beforeEach`) pour injecter les données de test plutôt qu’un simple fichier `test-data.ts`. Précisez aussi de mocker les appels réseau avec `page.route` pour rendre les tests indépendants d’un backend instable.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Implement CSP with nonces
Prevent XSS with strict CSP
DALL-E Prompt to Generate JavaScript Code
DALL-E, the image generation model developed by OpenAI, is not designed to produce executable JavaScript code. However, it can play a valuable complementary role in a JavaScript developer's workflow. DALL-E excels at creating visuals related to development: user interface mockups, architecture diagrams, data flow schemas, or illustrations to document your code. By crafting precise prompts, you can obtain visual representations of complex JavaScript concepts like closures, the event loop, or design patterns. These visuals then serve as references for implementing your code, creating attractive technical documentation, or designing educational materials. The approach is to use DALL-E as a rapid visual prototyping tool: generate a UI mockup, then translate it into JavaScript components. This method accelerates the design phase and reduces back-and-forth between designers and developers. In this guide, we offer optimized prompts to get the most out of DALL-E in your JavaScript development process, from UI prototyping to visual documentation of your code.
Create a High-Performance Scalable Redis Cache System
A complete prompt to design and implement a Redis cache system with invalidation strategies, error handling and monitoring.
Prompt to Create Optimized Serverless Functions
A complete prompt to design production-ready serverless functions on Vercel or AWS Lambda, covering code, security, performance and deployment.