I have this logic when starting NodeJS app:
const twiddleService = new twiddleService(
new twiddleClient(),
new UserRepository(),
new BusinessRepository()
);
const twiddleController = new twiddleController(twiddleService);
I've unit tested twiddleService by mocking twiddleClient.
Now I want to unit test twiddleController and mock twiddleService.
In my twiddleController.test.ts file I have
import { twiddleService } from '../../src/services/twiddle-service';
jest.mock('../../src/services/twiddle-service');
const twiddleController = new twiddleController(new twiddleService());
Obviously this doesn't work because twiddleService expects 3 arguments. I could mock twiddleClient and the repositories again, but ideally I wouldn't.
Basically the goal is I want to be able to do something like
jest.spyOn(TwiddleService, 'createBananas').mockResolvedValue('b');
So that I can unit test my controller.
What are best practices when it comes to solving this problem?
[Also I'm using typescript]