In my folder I have app.js, app.test.js and config.json
My config.json is filled with the correct information but I want to test the negative scenario, when the file does not contain any data data.length === 0
How can I replace the config.json for the test without actually replacing the file correct data?
const fileData = fs.readFileSync(path.resolve(__dirname, './config.json'));
const data = JSON.parse(fileData);
if (!data || data.length === 0) {
console.error('data is required!');
return;
}
...
// Test
it('#lambdaHandler should validate data configuration file', async() => {
const response = await app.myFunction();
});