Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 588 Bytes

prefer-spy-on.md

File metadata and controls

23 lines (15 loc) · 588 Bytes

Enforce using vi.spyOn (vitest/prefer-spy-on)

⚠️ This rule warns in the 🌐 all config.

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

Rule details

This rule triggers a warning if an object's property is overwritten with a vitest mock.

Date.now = vi.fn();
Date.now = vi.fn(() => 10);

These patterns would not be considered warnings:

vi.spyOn(Date, 'now');
vi.spyOn(Date, 'now').mockImplementation(() => 10);