Karma, PhantomJS and es6 Promises

前端 未结 5 1178
野的像风
野的像风 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:31

    as correctly pointed out by the author it is not able to recognize es6 promise. In order to load it, es6-promise module can be loaded with the help of webpack.ProvidePlugin and configuring it inside plugins array of webpack.

    plugins: [
            new webpack.ProvidePlugin({
                'Promise': 'es6-promise'
            })
        ]
    

    This seems to work for me!

提交回复
热议问题