# it-throws

> Wrapper around `assert.throws` and `assert.rejects`

Latest version **4.2.0** (published 2021-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install it-throws
pnpm add it-throws
yarn add it-throws
bun add it-throws
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2021-12-06 |
| First published | 2019-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mgenware |
| Maintainers | mgenware |

## Links

- npm: https://www.npmjs.com/package/it-throws
- Repository: https://github.com/mgenware/it-throws
- Issues: https://github.com/mgenware/it-throws/issues
- npm.io page: https://npm.io/package/it-throws

## Recent versions

- 4.2.0 (latest) — 2021-12-06
- 4.1.0 — 2021-05-12
- 4.0.0 — 2021-02-26
- 3.2.1 — 2019-12-25
- 3.2.0 — 2019-12-08
- 3.1.0 — 2019-10-21
- 3.0.1 — 2019-10-18
- 3.0.0 — 2019-10-18
- 2.0.0 — 2019-10-18
- 1.0.1 — 2019-10-17
- 1.0.0 — 2019-10-17
- 0.0.1 — 2019-10-17

## README

# it-throws

[![Build Status](https://github.com/mgenware/it-throws/workflows/Build/badge.svg)](https://github.com/mgenware/it-throws/actions)
[![npm version](https://img.shields.io/npm/v/it-throws.svg?style=flat-square)](https://npmjs.com/package/it-throws)
[![Node.js Version](http://img.shields.io/node/v/it-throws.svg?style=flat-square)](https://nodejs.org/en/)

Wrapper around `assert.throws` and `assert.rejects`.

### Installation

```sh
yarn add it-throws -D
```

### Usage

```js
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:

```js
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',
  });
});
```

---
_Source: https://npm.io/package/it-throws · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
