Mocking library for TypeScript
Fixed a null pointer exception occuring in some specific cases.
Fixed #48 Fixed verifying call count when not all optional arguments was given
Thanks to @Markus-Ende we can now mock propertie that aren't getters.
Please note, that stubbing properties that don't have getters only works if Proxy object is available (ES6).
Thanks to @dreef3 we got new spying feature!
Usage:
const foo: Foo = new Foo();
const spiedFoo = spy(foo);
when(spiedFoo.getBar(3)).thenReturn('one');
console.log(foo.getBar(3)); // 'one'
console.log(foo.getBaz()); // call to a real method
Thanks to @dyong0 we can now mock abstract and generic classes via https://github.com/NagRock/ts-mockito/pull/31
Fixed #28
All changes described in migration guide
Now we can change getter value:
// Creating mock
let mockedFoo:Foo = mock(Foo);
// stub getter before execution
when(mockedFoo.sampleGetter).thenReturn('three');
// Getting instance
let foo:Foo = instance(mockedFoo);
// prints three
console.log(foo.sampleGetter);