How to use a config file for Unit Test and another for production in NODE

441 Views Asked by At

I have a value in config file which is used in an IF condition and once that value is set I am not able to get the minimum coverage required.

As work around I created two json files one is production.json and other is test.json and I want to use test.json for Unit Testing and production.json for normal execution.

Please let me know if there is a better way to test this scenario.

1

There are 1 best solutions below

0
Gabriel Bleu On BEST ANSWER

You can do this with environment variables, prod settings should not be commited to SCM.

Check : dotenv