it-throws
v4.2.0
Published
Wrapper around `assert.throws` and `assert.rejects`
Downloads
15
Readme
it-throws
Wrapper around assert.throws
and assert.rejects
.
Installation
yarn add it-throws -D
Usage
import { itThrows, itRejects } from 'it-throws';
it('Throws', () => {
itThrows(() => {
throw new Error('foo');
}, 'foo');
});
it('Rejects', async () => {
await itRejects(Promise.reject(new Error('foo')), 'foo');
});
Is equivalent to:
import * as assert from 'assert';
it('Throws', () => {
assert.throws(
() => {
throw new Error('foo');
},
{
message: 'foo',
},
);
});
it('Rejects', async () => {
await assert.rejects(Promise.reject(new Error('foo')), {
message: 'foo',
});
});