Mocking library for TypeScript
Now we can use: reset(firstMock, secondMock, thirdMock)
, resetCalls(firstMock, secondMock, thirdMock)
Thanks to @bricka we got support for deepEqual
matcher.
If provided arguments to deepEqual
matcher are compatible no action is required.
But this update can cause compilation errors on existing code if provided values to deepEqual
type is not compatible. For example if expected param has more fields than provided one.
For easy migration you can use Partial
class.
Before:
const expectedParams = {
sampleField: 'sampleValue',
};
verify(mock.test(deepEqual(expectedParams))).once();
From 2.5.0:
const expectedParams: Partial<MyArgumentType> = {
sampleField: 'sampleValue',
};
verify(mock.test(deepEqual(expectedParams))).once();
It took a lot of time but... looks like we've got support for interfaces 🎉
Simply use generic type for mock
function and omit argument for it:
let mockedInterface: MyInterface = mock<MyInterface>();
Great thanks for @johanblumenberg who created first implementation and pushed me to support interfaces. Thanks for your patience.
Thanks to @johanblumenberg we got great new feature:
https://github.com/NagRock/ts-mockito#resolving--rejecting-promises
Fixed bug #80 that instance function worked different if Proxy was supported or not With Proxy support instance function always returned new object, without support it was always same instance. Now instance function always returns same object.