I've to run python and shell scripts in my node JS code. But to begin with, i've to mock the script calls. Is there any ways i can mock this python and shell scripts and send my expected response? Kindly share me your thoughts.
Below is the Code i use to call the script. When the PythonShell.run gets executed, i want to mock results and return my preferred response.
function callScript(){
var options = {
mode: 'text',
pythonPath: 'path/to/python',
pythonOptions: ['-u'],
scriptPath: 'path/to/my/scripts',
args: ['value1', 'value2', 'value3']
};
PythonShell.run('my_script.py', options, function (err, results) {
if (err) throw err;
// results is an array consisting of messages collected during execution
console.log('results: %j', results);
});
}