Search code examples
jsonnode.jsunit-testingnconf

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


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.


Solution

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

    Check : dotenv