node.js - 使用 Mocha 从单元测试进行电解质依赖注入(inject)

标签 node.js mocha.js

在电解质.js中我们通常创建一个模块:emodule.js(示例)

exports=module.exports=function(module1,module2,module3){



};


exports["@singleton"]=true;
exports["@require"] = ["module1","module2","module3"]

现在,如果我们想在 mocha 测试中实际模拟 module2,我们应该如何调用 emodule.js 以便对 module2 的所有调用都将重定向到模拟?感谢您的指点...

最佳答案

您是否见过其他依赖注入(inject)容器系统,例如 Bottlejs ( https://github.com/young-steveo/bottlejs ) 或 SimpleDiJs ( https://github.com/avighier/simple-dijs ) ?

关于node.js - 使用 Mocha 从单元测试进行电解质依赖注入(inject),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38064250/

相关文章:

javascript - mongodb 驱动程序不释放资源

javascript - WebdriverIO 是否有 "right at the end of the test"的 Hook (或等效解决方案)?

node.js - 如何为 fs.readFileSync() 捕获没有文件?

node.js - NodeJs : In Case when maxsockets are limited to 10, 如何限制globalAgent中的请求队列

node.js - 推荐用于 Node-RED 的 .gitignore

javascript - Chai 检查某物的存在

javascript - ES6 jsdom无法读取null的属性 'innerHTML'

node.js - 如何在azure虚拟机上托管nodejs api应用程序?

mysql - 在获取数据时用多列中的空字符串替换空值

node.js - 如何在 mocha 测试中使用 TypeScript 声明文件?