DEV Community

Discussion on: How to test throw with Jest

Collapse
 
grenguar profile image
Igor Soroka

For the async functions it can be:

it('Function should throw', async () => {
  await expect(yourFunction(params)).rejects.toThrow(new Error('some error'));
})
Enter fullscreen mode Exit fullscreen mode