Adds Decorator Based TS-Mockito Support to Alsatian + decorator based mock injection
Install
npm install alsatian-tsmockito
Decorators
Property Decorators
Defines that a mock should be injected in this property
Defines that a mock should be injected in this property which will be later injected in the object defined by the @InjectMocks() decorator.
Injection Methods
By default injectable mocks will be injected by assuming that the property name used in the test is equal to the one used in the class it should be injected in.
The @InjectableMock decorator accepts a parameter which can be used to override this default behavior. The argument is an interface which will be called during injection.
PropertyAccessInjection
PropertyAccessInjection can be used if the injection is done by setting a simple property on th test object. The name of the property is defined as argument.
Method Decorators
Reset Calls on Mocks
Reset Calls
Resets all calls on injectable mocks (@InjectableMock)
Resets all calls on NON injectable mocks (@Mock)
Resets all calls on all mocks (@Mock && @InjectableMock)
Reset Mocks
Restes calls and stubbing
Resets calls and stubbing on injectable mocks (@InjectableMock)
Resets calls and stubbing on NON injectable mocks (@Mock)
Resets calls and stubbing on all mocks (@Mock && @InjectableMock)
Example
See Demo.spec.ts in test folder: