vitest-class-mocking
CommunityInline class mocks to fix Vitest hoisting.
AuthorDavidTeju
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Fix "X is not a constructor" errors when mocking classes in Vitest. Hoisting in Vitest mocks can cause a class to be undefined at mock creation time, leading to runtime failures.
Core Features & Use Cases
- Inline class definitions inside the vi.mock factory to avoid hoisting issues
- Use vi.hoisted() for shared mocks across tests
- Mock multiple related classes with consistent patterns
Quick Start
Inline define mock classes inside the vi.mock() factory to avoid hoisting issues.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: vitest-class-mocking Download link: https://github.com/DavidTeju/shared-skills/archive/main.zip#vitest-class-mocking Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.