Skip to content

Latest commit

 

History

History
22 lines (14 loc) · 537 Bytes

prefer-spy-on.md

File metadata and controls

22 lines (14 loc) · 537 Bytes

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

🔧 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);