In Sinon, we can create a stub to a class:
const auditTrailClientStub = sinon.createStubInstance(AuditTrailClient);
auditTrailClientStub will have all methods the original class AuditTrailClient has.
For example, if AuditTrailClient has “method1”, “method2” and “method3”, then we can use these methods in auditTrailClientStub.
Do you how to mimic this functionality in Jest?
The only thing I found in Jest is:
jest.mock('<path-to-AuditTrailClient>', () => ({
method1: jest.fn(),
method2: jest.fn(),
method3: jest.fn(),
}));
The problem here is that I have to name all the methods in AuditTrailClient that I’ll need to mock. What if there are 10 methods in AuditTrailClient that I want to mock?
Is there an equivalent way to create a stub in Jest?