# @ava/babel-plugin-throws-helper

> Babel plugin for protecting against improper use of `t.throws()` in AVA

Latest version **4.0.0** (published 2019-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ava/babel-plugin-throws-helper
pnpm add @ava/babel-plugin-throws-helper
yarn add @ava/babel-plugin-throws-helper
bun add @ava/babel-plugin-throws-helper
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2019-08-11 |
| First published | 2017-03-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.9.4 <9 \|\| >=10.0.0 <11 \|\| >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Talmage |
| Maintainers | novemberborn, sindresorhus, vdemedes |
| Keywords | babel-plugin, babel, helper, ava, assertion, throws |

## Links

- npm: https://www.npmjs.com/package/@ava/babel-plugin-throws-helper
- Repository: https://github.com/avajs/babel-plugin-throws-helper
- Homepage: https://github.com/avajs/babel-plugin-throws-helper#readme
- Issues: https://github.com/avajs/babel-plugin-throws-helper/issues
- npm.io page: https://npm.io/package/@ava/babel-plugin-throws-helper

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2019-08-11
- 3.0.0 — 2018-08-28
- 3.0.0-beta.8 — 2018-08-12
- 3.0.0-beta.7 — 2018-06-13
- 3.0.0-beta.6 — 2018-05-30
- 3.0.0-beta.5 — 2018-05-25
- 3.0.0-beta.4 — 2018-04-08
- 3.0.0-beta.3 — 2018-02-14
- 3.0.0-beta.2 — 2018-01-31
- 3.0.0-beta.1 — 2018-01-27
- 2.0.0 — 2017-03-26

## README

# babel-plugin-throws-helper [![Build Status](https://travis-ci.org/avajs/babel-plugin-throws-helper.svg?branch=master)](https://travis-ci.org/avajs/babel-plugin-throws-helper)

> Babel plugin for protecting against improper use of `t.throws()` in [AVA](https://ava.li)

Probably not useful except as an internal plugin for the AVA test runner.

[Genesis of the idea.](https://github.com/sindresorhus/eslint-plugin-ava/issues/75)

## Issue

> I've seen a lot of incorrect use of the throws assertion in other test runner and even done the mistake myself sometimes. Now I'm beginning to see it with AVA too, so would be nice to be preemptive about it.
>
> People don't realize they need to wrap their call in a function, so many end up doing `t.throws(foo())` instead of `t.throws(() => foo());`. It's an easy mistake to make.

The difficulty is that `t.throws(foo())` is allowed if `foo()` returns a promise or a function. There is no good way to differentiate between the two at runtime. So providing a good error message is going to take some AST transform magic.


## Solution

See [`test.js.md`](test.js.md) for the transformation this plugin performs.

## License

MIT © [James Talmage](https://github.com/jamestalmage)

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