Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 761 Bytes

File metadata and controls

28 lines (21 loc) · 761 Bytes

vitest/prefer-called-exactly-once-with

📝 Prefer toHaveBeenCalledExactlyOnceWith over toHaveBeenCalledOnce and toHaveBeenCalledWith.

💼⚠️ This rule is enabled in the ✅ recommended config. This rule warns in the 🌐 all config.

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

Examples of incorrect code for this rule:

test('foo', () => {
  const mock = vi.fn()
  mock('foo')
  expect(mock).toHaveBeenCalledOnce()
  expect(mock).toHaveBeenCalledWith('foo')
})
test('foo', () => {
  const mock = vi.fn()
  mock('foo')
  expect(mock).toHaveBeenCalledExactlyOnceWith('foo')
})