jest-community/eslint-plugin-jest

Ensure expect(function).toThrow()

Open

#1,329 opened on Jan 15, 2023

 (3 comments) (0 reactions) (0 assignees)TypeScript (251 forks)auto 404
help wanted

Repository metrics

Stars
 (1,170 stars)
PR merge metrics
 (PR metrics pending)

Description

When is possible to determine if the expect(value) is not a function when used with .toThrow(), it must be an error.

const str = "any value";

expect(str).toThrow() // Not works.
const returnStr = () => "any value";

expect(returnStr).toThrow() // Not handle, but is a valid case (if returnStr() throws an exception).

Contributor guide