I need to write an unit test for the following classA. I do not want to test methodA but set a dummy method instead:
const classB = require('classB');
function a() {
const b = classB();
b.methodA();
}
I tried to use rewire:
const classA = rewire('classA');
const classBMock = require('classB');
classBMock.prototype.methodA = function() {
}
classA.__set__('classB', classBMock);
classA.a();
Is there a better way to achieve my goal?
Thanks!