Const
Assertion for testing if a function throws an error when called.
expect(() => { throw new Error('oops');}, 'to throw'); // passesexpect(() => 'hello', 'to throw'); // fails Copy
expect(() => { throw new Error('oops');}, 'to throw'); // passesexpect(() => 'hello', 'to throw'); // fails
function-to-throw-any
function
to-throw
Assertion for testing if a function throws an error when called.