我正在尝试改变内存中配置的值以进行测试,我尝试process.env.ALLOW_CONFIG_MUTATIONS=true
在应用程序中添加几个位置,以及通过命令行和我的.env
文件。
该config.util.getEnv('ALLOW_CONFIG_MUTATION')
方法总是返回未定义的。
我也尝试过使用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)
}
谢谢!