gpt4 book ai didi

node.js - 使用istanbul时,有没有办法动态要求config.js?

转载 作者:行者123 更新时间:2023-11-28 21:27:05 26 4
gpt4 key购买 nike

enter image description here

logEnable是写在config.js中的,请问有什么办法可以在测试的时候改变这个值吗?这样我就可以提高分支覆盖率。

最佳答案

您可以忽略测试中的部分代码:https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md

Skip an if or else path with /* istanbul ignore if */ or /* istanbul ignore else */ respectively.

For all other cases, skip the next 'thing' in the source with: /* istanbul ignore next */

或者添加一个测试,只检查启用和禁用日志记录的那些日志记录功能(您可以覆盖所需的模块,例如您的配置,例如使用 proxyquire:https://github.com/thlorenz/proxyquire)。

关于node.js - 使用istanbul时,有没有办法动态要求config.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37583721/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com