I am writing test cases for my Node.js application using Mocha. The test cases need an API key as an extra input option or parameter. The API key is private, so I don\'t wan
I have been reading quite some answers, most of them more complex than the actual solution has to be.
Let's say I have config.yml or config.json. In my case it's a YAML file.
First of all I install the yamljs dependency. It has a function called load.
Basically what I do:
const YAML = require('yamljs');
const ymlConfig = YAML.load('./config.yml');
Then I go for:
process.env.setting1 = ymlConfig.setting1;
process.env.setting2 = ymlConfig.setting2;
And of course - this is all done in your test file.