P
💻DeveloppementIntermediateAll AIs

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 :

  1. 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)
  2. 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
  3. Un fichier de fixtures (test-data.ts) contenant les données de test réutilisables.

  4. 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.describe pour regrouper les tests par fonctionnalité
  • Privilégie locator avec 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

Bootstrap an E2E test suite on an existing project without test coverageStandardize testing practices within a development teamPrepare an application for CI/CD deployment with reliable automated testsTrain junior developers on Playwright testing best practices

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 Optimizer

Comments

  • 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

💻DeveloppementIntermediateAll AIs

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.

383
💻DeveloppementIntermediateAll AIs

Implement rate limiting

Protect APIs from abuse

395
💻DeveloppementIntermediateAll AIs

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.

425
💻DeveloppementAdvancedAll AIs

Implement CSP with nonces

Prevent XSS with strict CSP

429