I'm working on a project that uses the value in process.env.APP_ENV
in order to select the appropiate config file for the current environment:
import prodParams from './production';
import stgParams from './staging';
import devParams from './development';
let params = devParams;
switch (process.env.APP_ENV) {
case 'production':
params = prodParams;
break;
case 'staging':
params = stgParams;
break;
default:
params = devParams;
}
export default params;
I'm trying to test this with the following code (not yet with assertions):
import params from '../../../parameters';
...
it.only('should return the appropriate config ', (done) => {
process.env.APP_ENV = 'production';
console.log(params);
done();
});
However when I set environment variable process.env.APP_ENV
as shown above it still reaches the module as undefined, so it always returns the development config instead of the production environment.
Setting aside the test part, the functionality is working fine, but I would like to test it regardless.
Any suggestions on how to fix this?
Aucun commentaire:
Enregistrer un commentaire