Karma, PhantomJS and es6 Promises

前端 未结 5 1180
野的像风
野的像风 2021-02-05 01:06

I am writing a JavaScript library that uses the new es6 promises. I can test the library in Firefox because promises are defined. However, when I try to test my code with Karma

5条回答
  •  日久生厌
    2021-02-05 01:15

    For Babel 6, we need install babel-polyfill to support promise.

    npm install --save-dev babel-polyfill
    

    and add a line in karma.conf.js within the files section

    files: [
      'node_modules/babel-polyfill/dist/polyfill.js',
      ....
    ]
    

    It's well documented in https://github.com/babel/karma-babel-preprocessor#polyfill

提交回复
热议问题