Const
Assertion for testing if a function throws an error matching specific criteria.
expect( () => { throw new Error('oops'); }, 'to throw', 'oops',); // passesexpect( () => { throw new Error('fail'); }, 'to throw', /error/i,); // passesexpect( () => { throw new Error('oops'); }, 'to throw', { message: 'oops' },); // passes Copy
expect( () => { throw new Error('oops'); }, 'to throw', 'oops',); // passesexpect( () => { throw new Error('fail'); }, 'to throw', /error/i,); // passesexpect( () => { throw new Error('oops'); }, 'to throw', { message: 'oops' },); // passes
Assertion for testing if a function throws an error matching specific criteria.