I would like to mock an object used inside called tested function. All I have found I another tickets was calling function in tested function, but I need to replace certain object that is used there. Is something like that possible in Jest?
util.test.js
describe('testname', function () {
it('import test', function () {
Utils.generateRandomPoints(10); // inside this function, I'd like to mock used object
});
});
utils.js
export function generateRandomPoints(arrayLength) {
const result = [];
for (let i = 0; i < 100; i++) {
// instead of "new Point" I'd like to use "new MockedPoint" for testing.
result.push(new Point(i));
}
return result;
};