{"id":20170,"library":"karma-babel-polyfill","title":"karma-babel-polyfill","description":"A Karma plugin that injects babel-polyfill into the test browser environment, ensuring that ES2015+ APIs (e.g., Promise, Map, Set) are available when running tests with Karma. Version 0.0.5 is the final release; the package has not been updated since 2016 and is considered deprecated in favor of using @babel/polyfill or @babel/regenerator directly with Karma's configuration. It requires karma as a peer dependency and is designed for use with older Babel 6 setups.","status":"deprecated","version":"0.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/jaganathanb/karma-babel-polyfill","tags":["javascript","karma","karma-plugin","babel","babel-polyfill"],"install":[{"cmd":"npm install karma-babel-polyfill","lang":"bash","label":"npm"},{"cmd":"yarn add karma-babel-polyfill","lang":"bash","label":"yarn"},{"cmd":"pnpm add karma-babel-polyfill","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to function","package":"karma","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not provide an ESM export.","wrong":"import karmaBabelPolyfill from 'karma-babel-polyfill';","symbol":"default","correct":"module.exports = require('karma-babel-polyfill');"},{"note":"In karma.conf.js, add the string 'babel-polyfill' to the frameworks array; do not use the package name.","wrong":"frameworks: ['karma-babel-polyfill']","symbol":"frameworks","correct":"frameworks: ['babel-polyfill']"},{"note":"Alternatively, the package can be listed in the plugins array if not auto-loaded.","wrong":"plugins: [require('karma-babel-polyfill')]","symbol":"plugins","correct":"plugins: ['karma-babel-polyfill']"}],"quickstart":{"code":"// karma.conf.js\nmodule.exports = function(config) {\n  config.set({\n    frameworks: ['mocha', 'babel-polyfill'], // Add 'babel-polyfill'\n    files: ['test/**/*.js'],\n    preprocessors: {\n      'test/**/*.js': ['babel']\n    },\n    babelPreprocessor: {\n      options: {\n        presets: ['env']\n      }\n    },\n    plugins: ['karma-babel-polyfill', 'karma-mocha', 'karma-chrome-launcher', 'karma-babel-preprocessor'],\n    browsers: ['ChromeHeadless'],\n    singleRun: true\n  });\n};\n\n// Install: npm install --save-dev karma-babel-polyfill karma karma-mocha karma-chrome-launcher karma-babel-preprocessor babel-preset-env","lang":"javascript","description":"Configures Karma to use babel-polyfill so that ES2015 features are available in test browsers."},"warnings":[{"fix":"Migrate to using @babel/polyfill or @babel/regenerator with Karma's single-run mode, or use core-js directly.","message":"Package has not been updated since 2016 and relies on deprecated babel-polyfill which is no longer maintained.","severity":"deprecated","affected_versions":">=0.0.1"},{"fix":"In karma.conf.js, set frameworks: ['babel-polyfill']","message":"Frameworks entry must be 'babel-polyfill' not 'karma-babel-polyfill'","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use require() or list in karma.conf.js as string.","message":"The package only provides CommonJS module; cannot be imported via ES import.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Update to @babel/polyfill and corresponding Karma plugins.","message":"Only works with Babel 6; not compatible with Babel 7 or @babel/core.","severity":"breaking","affected_versions":">=0.0.1"}],"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 karma-babel-polyfill\nThen add 'karma-babel-polyfill' to the plugins array in karma.conf.js.","cause":"Package not installed or not listed in plugins array in karma.conf.js.","error":"Error: Cannot find module 'karma-babel-polyfill'"},{"fix":"Do not manually call require('karma-babel-polyfill') in config; instead use the string 'babel-polyfill' in the frameworks array.","cause":"Incorrect usage of the module via import or require in wrong context.","error":"TypeError: babelPolyfill is not a function"},{"fix":"Ensure 'babel-polyfill' is in frameworks array. If using async/await, consider using @babel/plugin-transform-runtime.","cause":"babel-polyfill may not be loaded before test files; also may need add regenerator runtime.","error":"ReferenceError: regeneratorRuntime is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}