Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 744 Bytes

require-to-throw-message.md

File metadata and controls

40 lines (31 loc) · 744 Bytes

Require toThrow() to be called with an error message (vitest/require-to-throw-message)

⚠️ This rule warns in the 🌐 all config.

This rule triggers a warning if toThrow() or toThrowError() is used without an error message.

The following patterns are considered warnings:

test('foo', () => {
  expect(() => {
	throw new Error('foo')
  }).toThrow()
})

test('foo', () => {
  expect(() => {
	throw new Error('foo')
  }).toThrowError()
})

The following patterns are not considered warnings:

test('foo', () => {
  expect(() => {
	throw new Error('foo')
  }).toThrow('foo')
})

test('foo', () => {
  expect(() => {
	throw new Error('foo')
  }).toThrowError('foo')
})