# vitest/prefer-called-once 📝 Enforce using `toBeCalledOnce()` or `toHaveBeenCalledOnce()`. 🚫 This rule is _disabled_ in the 🌐 `all` config. 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). ## Rule Details This rule aims to enforce the use of `toBeCalledOnce()` or `toHaveBeenCalledOnce()` over `toBeCalledTimes(1)` or `toHaveBeenCalledTimes(1)`. Examples of **incorrect** code for this rule: ```ts test('foo', () => { const mock = vi.fn() mock('foo') expect(mock).toBeCalledTimes(1) expect(mock).toHaveBeenCalledTimes(1) }) ``` Examples of **correct** code for this rule: ```ts test('foo', () => { const mock = vi.fn() mock('foo') expect(mock).toBeCalledOnce() expect(mock).toHaveBeenCalledOnce() }) ```