Registry / testing / karma-babel-polyfill

karma-babel-polyfill

JSON →
library0.0.5jsnpmunverified

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.

npm install karma-babel-polyfill
INSTALL
IMPORT
SIG · KARMA-BABEL-POLYFI
K
karma-babel-polyfill
testingjavascriptv0.0.5
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
module.exports = require('karma-babel-polyfill');
import karmaBabelPolyfill from 'karma-babel-polyfill';
This package is CommonJS-only and does not provide an ESM export.
frameworks
frameworks: ['babel-polyfill']
frameworks: ['karma-babel-polyfill']
In karma.conf.js, add the string 'babel-polyfill' to the frameworks array; do not use the package name.
plugins
plugins: ['karma-babel-polyfill']
plugins: [require('karma-babel-polyfill')]
Alternatively, the package can be listed in the plugins array if not auto-loaded.

Configures Karma to use babel-polyfill so that ES2015 features are available in test browsers.

// karma.conf.js module.exports = function(config) { config.set({ frameworks: ['mocha', 'babel-polyfill'], // Add 'babel-polyfill' files: ['test/**/*.js'], preprocessors: { 'test/**/*.js': ['babel'] }, babelPreprocessor: { options: { presets: ['env'] } }, plugins: ['karma-babel-polyfill', 'karma-mocha', 'karma-chrome-launcher', 'karma-babel-preprocessor'], browsers: ['ChromeHeadless'], singleRun: true }); }; // Install: npm install --save-dev karma-babel-polyfill karma karma-mocha karma-chrome-launcher karma-babel-preprocessor babel-preset-env
Debug
Known issues
deprecatedPackage has not been updated since 2016 and relies on deprecated babel-polyfill which is no longer maintained.
fix
Migrate to using @babel/polyfill or @babel/regenerator with Karma's single-run mode, or use core-js directly.
affects: >=0.0.1
gotchaFrameworks entry must be 'babel-polyfill' not 'karma-babel-polyfill'
fix
In karma.conf.js, set frameworks: ['babel-polyfill']
affects: >=0.0.1
gotchaThe package only provides CommonJS module; cannot be imported via ES import.
fix
Use require() or list in karma.conf.js as string.
affects: >=0.0.1
breakingOnly works with Babel 6; not compatible with Babel 7 or @babel/core.
fix
Update to @babel/polyfill and corresponding Karma plugins.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'karma-babel-polyfill'
Package not installed or not listed in plugins array in karma.conf.js.
fix
Run: npm install --save-dev karma-babel-polyfill
Then add 'karma-babel-polyfill' to the plugins array in karma.conf.js.
TypeError: babelPolyfill is not a function
Incorrect usage of the module via import or require in wrong context.
fix
Do not manually call require('karma-babel-polyfill') in config; instead use the string 'babel-polyfill' in the frameworks array.
ReferenceError: regeneratorRuntime is not defined
babel-polyfill may not be loaded before test files; also may need add regenerator runtime.
fix
Ensure 'babel-polyfill' is in frameworks array. If using async/await, consider using @babel/plugin-transform-runtime.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
karmarequiredpeer dependency required for plugin to function
Agent activity
4 hits · last 30 days
node
4
Resources
karma-babel-polyfill — npm install karma-babel-polyfill · libregistry