Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 517 Bytes

prefer-mock-promise-shorthand.md

File metadata and controls

16 lines (12 loc) · 517 Bytes

Enforce mock resolved/rejected shorthands for promises (vitest/prefer-mock-promise-shorthand)

⚠️ This rule warns in the 🌐 all config.

🔧 This rule is automatically fixable by the --fix CLI option.

// bad
vi.fn().mockReturnValue(Promise.reject(42))
vi.fn().mockImplementation(() => Promise.resolve(42))

// good
vi.fn().mockRejectedValue(42)
vi.fn().mockResolvedValue(42)