Skip to main content
Exécutez n'importe quel Skill dans Manus
en un clic

vitest-esm-class-mock

Étoiles2
Forks0
Mis à jour7 avril 2026 à 09:57

How to mock class constructors (like WebClient from @slack/web-api) in vitest v4 with ESM modules. Trigger: tests fail with "mock is not being treated as a constructor" or `new ClassName()` returns undefined after vi.clearAllMocks(). Solves the problem of vi.fn().mockImplementation() losing its implementation across test lifecycle hooks.

Installation

Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.

SKILL.md
readonly