@otbe asked me to implement some decorators to help during unit testing. This is really interesting and I believe that there are a lot of things that we can use to improve the developers testing experience.
My plan is to develop an stand alone npm package. It will contain some testing utils.
The initial request refers to decorators like @mock and @mockSingleton:
export function mock<Interface> (binding: string|Symbol|INewable<Interface>) {
return (targetClass: INewable<Interface>): void => {
injectable()(targetClass);
kernel.unbind(binding);
kernel.bind(binding).to(targetClass);
}
}
@mock(MyService)
class MyServiceMock {
name:string = 'foo';
}
function mockSingleton<Interface> (binding: string|Symbol|INewable<Interface>) {
return (targetClass: INewable<Interface>): void => {
kernel.unbind(binding);
kernel.bind(binding).toConstantValue(new targetClass);
}
}
I'm creating this issue to keep track of all the requests and ideas.
If you want to suggest something please add a comment or join us on Gitter. I will collect the feedback from the chat and add it here...
@otbe asked me to implement some decorators to help during unit testing. This is really interesting and I believe that there are a lot of things that we can use to improve the developers testing experience.
My plan is to develop an stand alone npm package. It will contain some testing utils.
The initial request refers to decorators like
@mockand@mockSingleton:I'm creating this issue to keep track of all the requests and ideas.
If you want to suggest something please add a comment or join us on Gitter. I will collect the feedback from the chat and add it here...