P
đź’»DeveloppementIntermediateAll AIs

Create effective mocks and stubs

Isolate tests from external dependencies

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

I need to mock [EXTERNAL_SERVICE: third-party API, database, file system] for [MODULE_NAME] tests. Show me how to create mocks with [Jest/Vitest] that: simulate normal and error responses, are reusable across tests, make no real network calls, and verify that the code properly calls the right methods with the right arguments.

Personalize this prompt with Léa

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Use Cases

Isolate tests from external dependencies

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 des mocks réutilisables, encapsule chaque simulation dans une fonction factory exportable (ex: `mockFetchSuccess(data)`). Utilise `vi.mock` (ou `jest.mock`) avec une factory pour remplacer tout le module. Ajoute `beforeEach` avec `vi.clearAllMocks()` pour isoler les tests. Vérifie les appels avec `.toHaveBeenCalledWith(exactArgs)`. Cela évite la duplication et assure la fiabilité.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

đź’»DeveloppementIntermediateAll AIs

Implement rate limiting

Protect APIs from abuse

396
đź’»DeveloppementIntermediateAll AIs

Set up semantic versioning automation

Automate semantic versioning

406
đź’»DeveloppementIntermediateAll AIs

Prompt DALL-E to Create a Prototype

Creating visual prototypes is a crucial step in any product design process. Traditionally reserved for designers with specialized tools like Figma or Sketch, this phase can now be accelerated with DALL-E. By generating realistic visual mockups from text descriptions, DALL-E allows entrepreneurs, product managers, and developers to quickly materialize their ideas without advanced graphic skills. Whether you want to visualize a mobile app interface, a physical product, or an architectural concept, DALL-E transforms your descriptions into compelling visual representations. This approach considerably reduces the time between ideation and the first visual iteration, going from several days to a few minutes. The AI-generated prototype then serves as a basis for discussion with stakeholders, investors, or potential users, facilitating the collection of concrete feedback before investing in costly development. Mastering the art of prompting for prototype generation with DALL-E thus becomes a strategic skill for anyone wishing to innovate quickly and effectively.

447
đź’»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.

426