Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 495 Bytes

README.md

File metadata and controls

26 lines (17 loc) · 495 Bytes

mock-class

Mock any ES6 class, record calls of object methods, and mock return values and behavior.

 class Car {
     public go() {
        console.log('going');
     }
     
     public stop() {
        console.log('stopped');
     }
 
 }


 const carMock = ClassMocker.mockClass<Car>(Car);
 
 carMock.mock().method('stop').willReturn('test mocked return value');
 
 const result = carMock.stop();
 
 carMock.amountOfCalls() // 1
 expect(result).toBe('test mocked return value');