{"id":19051,"library":"babel-plugin-espower","title":"babel-plugin-espower","description":"Babel plugin for power-assert that transforms assertion expressions (assert, assert.ok, assert.equal, etc.) at build time to produce detailed, tree-structured failure messages. Current stable version is 3.0.1 (for Babel 7+). Release cadence is low, driven by power-assert ecosystem updates. Key differentiator: unlike generic assertion libraries, it leverages Babel AST rewriting to embed variable values and expression results into assertion output, enabling richer debugging without runtime instrumentation. Compatible only with Babel 7; separate major versions exist for Babel 6 (2.x) and Babel 5 (1.x).","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/power-assert-js/babel-plugin-espower","tags":["javascript","assert","assertion","babel","babel-plugin","power-assert","test","testing","transform"],"install":[{"cmd":"npm install babel-plugin-espower","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-espower","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-espower","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Babel plugin API (Babel 7). Must be installed alongside.","package":"@babel/core","optional":false}],"imports":[{"note":"Package exports a single function; ESM import is recommended for Babel 7 projects. CJS require works in Node.js but may not be compatible with Babel's plugin resolution across bundlers.","wrong":"const espower = require('babel-plugin-espower')","symbol":"default","correct":"import espower from 'babel-plugin-espower'"},{"note":"In .babelrc or babel.config.js, use the string name. The actual import is rarely needed; Babel resolves strings to the module internally.","wrong":"plugins: [require('babel-plugin-espower')]","symbol":"Plugin","correct":"plugins: ['babel-plugin-espower']"},{"note":"When using Babel API, the plugin can be specified as a string. The imported function is only needed for advanced usage like custom options (none documented).","wrong":"babel.transform(code, { plugins: [espower] })","symbol":"Default (Babel API)","correct":"babel.transform(code, { plugins: ['babel-plugin-espower'] })"}],"quickstart":{"code":"// Install: npm install --save-dev @babel/core @babel/preset-env babel-plugin-espower power-assert mocha\n// Create babel.config.js:\nmodule.exports = {\n  presets: [['@babel/preset-env', { targets: { node: 'current' } }]],\n  plugins: ['babel-plugin-espower']\n};\n\n// test.js\nimport assert from 'power-assert';\nconst alice = { name: 'alice' };\nconst bob = { name: 'bob' };\nassert(`${alice.name} and ${bob.name}` === `bob and alice`);\n\n// Run: npx mocha --require @babel/register test.js","lang":"javascript","description":"Shows a complete example of configuring babel-plugin-espower with Babel 7 and running a mocha test with power-assert."},"warnings":[{"fix":"Use babel-plugin-espower@2 for Babel 6, babel-plugin-espower@1 for Babel 5, or upgrade to Babel 7.","message":"babel-plugin-espower v3 is incompatible with Babel 6. You must use v2 for Babel 6 and v1 for Babel 5.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Place 'babel-plugin-espower' last in the plugins array in your Babel config.","message":"babel-plugin-espower must be applied after all other syntax transforms (e.g., after preset-env) to work correctly.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure you have `import assert from 'power-assert'` (or `const assert = require('power-assert')`) in every test file using assert.","message":"power-assert must be imported in test files for babel-plugin-espower to have effect; the plugin transforms calls to assert, assert.ok, etc.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to Babel 7 and use babel-plugin-espower v3.","message":"babel-plugin-espower v2 is deprecated for Babel 6 users; actively maintain for Babel 7 only.","severity":"deprecated","affected_versions":"2.x"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev babel-plugin-espower`. Ensure Babel version matches: Babel 7 uses v3, Babel 6 uses v2, Babel 5 uses v1.","cause":"babel-plugin-espower is not installed or version mismatched with Babel.","error":"Error: Cannot find module 'babel-plugin-espower'"},{"fix":"Add 'babel-plugin-espower' to your Babel plugins configuration (after presets) and ensure test files import power-assert.","cause":"babel-plugin-espower is not applied to the test file, or power-assert import is missing.","error":"AssertionError: expected [...] to deeply equal [...]  (no power-assert output)"},{"fix":"Check Babel version: Babel 7 -> babel-plugin-espower@3, Babel 6 -> @2, Babel 5 -> @1.","cause":"Using a version of babel-plugin-espower incompatible with your Babel version (e.g., v3 with Babel 6).","error":"Error: Plugin or preset file \"babel-plugin-espower\" is not a function."},{"fix":"Ensure babel-plugin-espower is listed last in the plugins array, after all presets and other plugins.","cause":"babel-plugin-espower running before syntax transforms, causing AST nodes to not be fully parsed.","error":"TypeError: Cannot read properties of undefined (reading 'type')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}