Skip to main content
Run any Skill in Manus
with one click

vitest-esm-class-mock

Stars2
Forks0
UpdatedApril 7, 2026 at 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

Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.

SKILL.md
readonly