如何使用ES6模块来模拟单元测试的依赖关系 [英] How to mock dependencies for unit tests with ES6 Modules
问题描述
我正在尝试使用webpack + traceur将Ecmascript 6模块弄到ES5 CommonJS上,但是我无法成功地对它们进行单元测试。
我尝试使用Jest + traceur预处理器,但是automocking和依赖名称似乎变得很困难,加上我似乎无法使sourceMaps与Jest和node-inspector调试一起使用。
<有没有更好的框架来进行单元测试ES6模块?
我实际上是通过删除Jest, Karma + Jasmine + Webpack,并使用 https://github.com/jhnns/rewire 来模拟依赖关系
I'm trying to fiddle with Ecmascript 6 modules using webpack + traceur to transpile to ES5 CommonJS, but I'm having trouble successfully unit testing them.
I tried using Jest + traceur preprocessor, but the automocking and dependency names seem to get screwy, plus I can't seem to get sourceMaps to work with Jest and node-inspector debugging.
Is there a better framework to unit test ES6 modules?
I actually got this to work by dropping Jest and going with Karma + Jasmine + Webpack and using https://github.com/jhnns/rewire to mock dependencies
这篇关于如何使用ES6模块来模拟单元测试的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!