{"id":19038,"library":"babel-plugin-coverage","title":"babel-plugin-coverage","description":"A Babel 6.x plugin that instruments JavaScript code with Istanbul-compatible `__coverage__` variables for test coverage collection. v1.0.0 is the latest stable release. This fork of babel-plugin-__coverage__ adds istanbul-style ignore hints and alters statement counting for conditionals. It works with Karma and mocha/nyc without additional tooling. No ongoing development; exists as a legacy solution for projects stuck on Babel 6.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/yyx990803/babel-plugin-coverage","tags":["javascript","babel","coverage","istanbul","tdd","test","unit"],"install":[{"cmd":"npm install babel-plugin-coverage","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-coverage","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-coverage","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Babel plugin API","package":"babel-core","optional":false}],"imports":[{"note":"This is a Babel plugin, not imported in user code. Configure in .babelrc under plugins.","wrong":"const coverage = require('babel-plugin-coverage')","symbol":"default","correct":"// No default import; use .babelrc config"},{"note":"In .babelrc, use the short name 'coverage'. The full name also works but is unnecessary.","wrong":"{\n  \"plugins\": [ [ \"babel-plugin-coverage\", {} ] ]\n}","symbol":"plugin","correct":"{\n  \"plugins\": [ \"coverage\" ]\n}"},{"note":"Options can include 'ignore' (glob pattern) or 'only' (glob pattern). Note: glob patterns should include trailing slash for directories.","wrong":"{\n  \"plugins\": [ [ \"babel-plugin-coverage\", { \"ignore\": \"test\" } ] ]\n}","symbol":"options","correct":"{\n  \"plugins\": [ [ \"coverage\", { \"ignore\": \"test/\" } ] ]\n}"}],"quickstart":{"code":"// .babelrc\n{\n  \"env\": {\n    \"test\": {\n      \"plugins\": [ \"coverage\" ]\n    }\n  }\n}\n\n// Install: npm install --save-dev babel-plugin-coverage\n// Then run tests with Karma + karma-coverage or mocha + nyc.","lang":"javascript","description":"Shows basic setup in .babelrc to enable coverage only during test environments."},"warnings":[{"fix":"Use @babel/plugin-istanbul for Babel 7+.","message":"babel-plugin-coverage only works with Babel 6.x. It is incompatible with Babel 7+.","severity":"breaking","affected_versions":"all"},{"fix":"In package.json, set \"nyc\": { \"include\": [ \"/\" ] } or equivalent.","message":"When using with NYC, you must configure NYC not to instrument your code via nyc.include.","severity":"gotcha","affected_versions":"all"},{"fix":"Use karma-coverage or nyc to generate HTML/lcov reports.","message":"This plugin does not generate any coverage report. It only instruments code. You still need a coverage reporter (karma-coverage, nyc).","severity":"gotcha","affected_versions":"all"},{"fix":"Consider migrating to @babel/plugin-istanbul for newer Babel versions and istanbul compatibility.","message":"The original babel-plugin-__coverage__ and this fork are effectively in maintenance mode. No new features or updates.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"search_vec":"'6':7,71 'add':37 'addit':56 'alter':44 'babel':2,6,34,70,73 'babel-plugin':33 'babel-plugin-coverag':1 'code':13 'collect':23 'compat':17 'condit':48 'count':46 'coverag':4,18,22,36,74 'develop':60 'exist':61 'fork':31 'hint':42 'ignor':41 'instrument':11 'istanbul':16,39,75 'istanbul-compat':15 'istanbul-styl':38 'javascript':12,72 'karma':52 'latest':27 'legaci':64 'mocha/nyc':54 'ongo':59 'plugin':3,9,35 'project':67 'releas':29 'solut':65 'stabl':28 'statement':45 'stuck':68 'style':40 'tdd':76 'test':21,77 'tool':57 'unit':78 'v1.0.0':24 'variabl':19 'without':55 'work':50 'x':8","created_at":"2026-04-25T11:15:43.289056+00:00","updated_at":"2026-04-25T11:15:43.289056+00:00","problems":[{"fix":"npm install --save-dev babel-preset-env and add \"presets\": [\"env\"] to .babelrc","cause":"Missing or misconfigured babel-preset-env in .babelrc","error":"Couldn't find preset \"env\" relative to directory"},{"fix":"Use @babel/plugin-istanbul or downgrade to Babel 6.","cause":"Using a Babel 6 plugin with Babel 7+","error":"Error: Plugin/Preset files are not allowed to export objects, only functions."},{"fix":"Use Node.js >= 4.0 and <= 10.x (verify package.json engines if present).","cause":"Node.js version incompatible; the package may require older Node","error":"EBADENGINE: Unsupported engine for babel-plugin-coverage@1.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/yyx990803/babel-plugin-coverage","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/babel-plugin-coverage","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}