I have the following code:
const {compose} = require('./compose');
const complicatedFunction = async function (argA, argB) {
const result = await getValue(argA)
const value = await getValue2(argB)
const composition = compose(result, value)
validator(composition)
return composition
I am calling the complicatedFunction to test the "validator" function. To test the validator function, I must stub the compose function to make it return whatever I want.
It would be easy to stub it and pass it as an argument, but it is not an option. How can stub compose to make it return any value? I know that proxyquire allows to mock dependencies but I don't understand how could I insert it in that situation