{"id":19028,"library":"babel-plugin-ava-throws-helper","title":"babel-plugin-ava-throws-helper","description":"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())`.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/avajs/babel-plugin-ava-throws-helper","tags":["javascript","babel-plugin","babel","helper","ava","assertion","throws"],"install":[{"cmd":"npm install babel-plugin-ava-throws-helper","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-ava-throws-helper","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-ava-throws-helper","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Babel plugin requires Babel's transformation API","package":"babel-core","optional":false}],"imports":[{"note":"Plugin is typically used in .babelrc or babel.config.js as a string 'babel-plugin-ava-throws-helper'.","wrong":"const plugin = require('babel-plugin-ava-throws-helper')","symbol":"default","correct":"import plugin from 'babel-plugin-ava-throws-helper'"},{"note":"The full package name must be used in .babelrc to avoid ambiguity.","wrong":"{\n  \"plugins\": [\"ava-throws-helper\"]\n}","symbol":"ava-throws-helper","correct":"// .babelrc\n{\n  \"plugins\": [\"babel-plugin-ava-throws-helper\"]\n}"}],"quickstart":{"code":"// Install the plugin\nnpm install babel-plugin-ava-throws-helper --save-dev\n\n// .babelrc\n{\n  \"plugins\": [\"babel-plugin-ava-throws-helper\"]\n}\n\n// Using AVA test\nimport test from 'ava';\n\ntest('throws test', t => {\n  t.throws(() => { throw new Error('err'); }); // OK\n});\n\ntest('invalid throws', t => {\n  // This would be transformed to produce a helpful error at runtime\n  t.throws(new Error('err'));\n});","lang":"javascript","description":"Shows installation, Babel configuration, and usage of the plugin to catch incorrect t.throws() calls."},"warnings":[{"fix":"Ensure AVA version compatibility; this plugin is internal and may be removed in future AVA releases.","message":"This plugin only works with AVA's t.throws() and may not be compatible with future AVA versions.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always wrap t.throws() arguments in a function as best practice.","message":"The plugin does not prevent all runtime errors; it only aids detection when used via Babel.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install the missing preset: npm install babel-preset-stage-2 --save-dev","cause":"Missing required Babel preset","error":"Error: Couldn't find preset \"stage-2\" relative to directory"},{"fix":"Ensure AVA is installed and you are running tests with 'npx ava'","cause":"AVA test runner not properly set up","error":"ReferenceError: test is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}