javascript - Karma, PhantomJS and es6 Promises -


i writing javascript library uses new es6 promises. can test library in firefox because promises defined. however, when try test code karma , phantomjs, error can't find variable: promise.. guessing because phantomjs browser doesn't support es6 promises yet.

how can configure karma bring in polyfill promises?

you can pull in babel polyfill installing babel polyfill:

npm install --save-dev babel-polyfill 

and include polyfill file before source , test files within files section of karma.conf.js:

files: [   'node_modules/babel-polyfill/dist/polyfill.js',   'index.js',   //could /src/**/*.js   'index.spec.js' //could /test/**/*.spec.js ], 

unless know target browsers support promises, want apply polyfill released build too.

if you're feeling adventurous can use browserify pull files in make testing more modular, , use babelify transpile es6 es5. i've created sample project these , working test involving promise (running on phantomjs2) reference.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -