【发布时间】:2018-12-06 17:52:00
【问题描述】:
我正在尝试更改内存中配置的值以进行测试,我尝试在应用程序的多个位置以及通过命令行和我的.env 文件添加process.env.ALLOW_CONFIG_MUTATIONS=true。
config.util.getEnv('ALLOW_CONFIG_MUTATION') 方法总是返回 undefined。
根据我在网上看到的示例,我还尝试使用importFresh 和MockRequest,这两种方法都不允许我更改内存中的配置,然后稍后重置该值。
有人对此有任何想法吗?
更新:这是我正在尝试完成的示例
const config = require (config);
const app = new App(config)
it(`does a thing with base config`, () => { ... }
it('does a thing with modified config, () => {
// here i would need to modify my config value and
// have it change the original config that's currently in
// application memory
config = newConfig
expect(config.get('newValues')).to.equal(true)
}
谢谢!
【问题讨论】:
标签: javascript node.js node-modules node-config