You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following situation and wanted to understand what would be the best way to handle it.
So in my project I am using nconf for managing configuration settings in applications. and for running test-cases I set nconf with test.json file which have all configuration variables(like PORT, DB_HOST, S3_BUCKET_URL etc)
and following is the module which I wan to rewire in my test-case module.js
const nconf = require('nconf')
...
// I have added below code for simplicity
if(!nconf.get('port')){
throw error('error')
}
...
in my test-case I am rewiring a module(this module also makes use of nconf) test-case.js
const nconf = require('nconf') // here I could access all env vars PORT, DB_HOST etc
const rewire = require('rewire')
const myModule = rewire('path_to_module') // here I would get error and test-execution stop's here
// because nconf.get('port') is undefined
How can I resolve this issue, so nconf retains its value when rewiring the module
The text was updated successfully, but these errors were encountered:
chavan-gopal
changed the title
nconf values are undefined when module is rewire
nconf values are undefined when a module is rewire
Dec 29, 2023
I have the following situation and wanted to understand what would be the best way to handle it.
So in my project I am using nconf for managing configuration settings in applications. and for running test-cases I set nconf with test.json file which have all configuration variables(like PORT, DB_HOST, S3_BUCKET_URL etc)
and following is the module which I wan to rewire in my test-case
module.js
in my test-case I am rewiring a module(this module also makes use of nconf)
test-case.js
How can I resolve this issue, so nconf retains its value when rewiring the module
The text was updated successfully, but these errors were encountered: