How can I mock the imports of an ES6 module?

后端 未结 8 1564
醉话见心
醉话见心 2020-11-28 21:33

I have the following ES6 modules:

File network.js

export function getDataFromServer() {
  return ...
}

File widget.js<

8条回答
  •  眼角桃花
    2020-11-28 21:38

    I recently discovered babel-plugin-mockable-imports which handles this problem neatly, IMHO. If you are already using Babel, it's worth looking into.

提交回复
热议问题