I recently transitioned from Java to TypeScript and am trying to find the equivalent of java junit(Mockito) in TypeScript. In junit, we can define the behavior of dependencies and return responses based on test case demands. Is there a similar way to do this in jest as well? Where I can simply define: when(dependencyFunction()).then(mockResponse1);
And in different tests: when(dependencyFunction()).then(mockResponse2);
This is what my TypeScript class looks like:
class ABC {
static fun1(){
const xyz = await dependency();
return xyz === 'DONE';
}
}
Here, I want to write test cases where I can specify the mocked response for each case.