I'm trying to mutate the value of my config in memory for testing, I've tried adding process.env.ALLOW_CONFIG_MUTATIONS=true
in several spots in the application, as well as through the command line and my .env
file.
The config.util.getEnv('ALLOW_CONFIG_MUTATION')
method always returns undefined.
I've also tried using importFresh
and MockRequest
as per examples I've seen online, neither of which allow me to mutate the config in memory, and then reset the value later.
Does anyone have any idea about this?
Update : here's an example of what I'm trying to accomplish
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)
}
Thanks!
If it is the same config module that I have used (I think I is) then add a custom-environment-variables.js
OR test.js
with you test config.
test.js will need an ENV=test
to work and the custom-environment-variables need something like (for Mac's and NPM) $ npm run funcTest
-> yarn serverRunning && NODE_ENV=test wdio wdio.conf.js
.
the JSON will look something like
{
test: 'Value'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.