Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i suppress "NODE_ENV value of 'test' did not match any deployment config file names." warnings? #386

Closed
nrser opened this issue Feb 15, 2017 · 5 comments

Comments

@nrser
Copy link

nrser commented Feb 15, 2017

i have mocha tests being run in a spawned process with NODE_ENV=test and i'm getting these warnings in the output:

WARNING: NODE_ENV value of 'test' did not match any deployment config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode

i checked out #309 and read the source... it doesn't seem like there is any way turn them off?

@markstos
Copy link
Collaborator

The answer is on the linked web page, under the section about the specific warning you got.

@nrser
Copy link
Author

nrser commented Feb 16, 2017

you mean creating a file for it to find? i understand that would stop the warning. i wanted to know if there was a way to simply suppress it's display. if there's not, ok, there's not. it's a library though so not sure i'll always have control of the end user config.

@markstos
Copy link
Collaborator

No, there's not a second method. Just create the file.

@morphatic
Copy link

I found another workaround. In my package.json file where I set up my test script, I changed it to the following:

{
  ...
  "scripts": {
    "test": "NODE_ENV= jest",
    ...
  },
  ...
}

This prevents jest (or mocha in your case) from setting the NODE_ENV variable to "test" which in turn means that the config package won't look for the config/test.json file. Take special note that there is a space between NODE_ENV= and jest in that script. Alternatively you could set NODE_ENV to something else, but the config package would look for a JSON file with that name in the config/ directory and you'd be back to the place you started.

@capan
Copy link

capan commented Dec 22, 2019

I know this is not the best practice but I've wrapped the warning logs in config.js with an if to get rid of the warning messages;

 if (prefix !== 'WARNING: ') {
      console.error(prefix + msg);
      console.error(prefix + seeURL);
    }

freddidierRTE added a commit to opfab/operatorfabric-core that referenced this issue Jul 25, 2023
This avoid warning on build during testing
see node-config/node-config#386

Signed-off-by: freddidierRTE <frederic-f.didier@rte-france.com>
vlo-rte pushed a commit to opfab/operatorfabric-core that referenced this issue Jul 25, 2023
This avoid warning on build during testing
see node-config/node-config#386

Signed-off-by: freddidierRTE <frederic-f.didier@rte-france.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants