Registry / testing / babel-plugin-ava-throws-helper

babel-plugin-ava-throws-helper

JSON →
library1.0.0jsnpmunverified

A Babel plugin that provides compile-time protection against improper use of `t.throws()` in the AVA test framework. It transforms code to detect when a value rather than a function is passed, issuing clear error messages. This plugin is internal to AVA and not intended for direct use; version 1.0.0 is the current stable release, with no recent updates. It differs from eslint-plugin-ava by offering a more robust, AST-based solution for a common mistake where users write `t.throws(foo())` instead of `t.throws(() => foo())`.

npm install babel-plugin-ava-throws-helper
INSTALL
IMPORT
SIG · BABEL-PLUGIN-AVA-T
B
babel-plugin-ava-throws-helper
testingjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import plugin from 'babel-plugin-ava-throws-helper'
const plugin = require('babel-plugin-ava-throws-helper')
Plugin is typically used in .babelrc or babel.config.js as a string 'babel-plugin-ava-throws-helper'.
ava-throws-helper
// .babelrc { "plugins": ["babel-plugin-ava-throws-helper"] }
{ "plugins": ["ava-throws-helper"] }
The full package name must be used in .babelrc to avoid ambiguity.

Shows installation, Babel configuration, and usage of the plugin to catch incorrect t.throws() calls.

// Install the plugin npm install babel-plugin-ava-throws-helper --save-dev // .babelrc { "plugins": ["babel-plugin-ava-throws-helper"] } // Using AVA test import test from 'ava'; test('throws test', t => { t.throws(() => { throw new Error('err'); }); // OK }); test('invalid throws', t => { // This would be transformed to produce a helpful error at runtime t.throws(new Error('err')); });
Debug
Known issues
breakingThis plugin only works with AVA's t.throws() and may not be compatible with future AVA versions.
fix
Ensure AVA version compatibility; this plugin is internal and may be removed in future AVA releases.
affects: >=1.0.0
gotchaThe plugin does not prevent all runtime errors; it only aids detection when used via Babel.
fix
Always wrap t.throws() arguments in a function as best practice.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Couldn't find preset "stage-2" relative to directory
Missing required Babel preset
fix
Install the missing preset: npm install babel-preset-stage-2 --save-dev
ReferenceError: test is not defined
AVA test runner not properly set up
fix
Ensure AVA is installed and you are running tests with 'npx ava'
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
babel-corerequiredBabel plugin requires Babel's transformation API
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
babel-plugin-ava-throws-helper — npm install babel-plugin-ava-throws-helper · libregistry