New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic methods cannot be mocked easily #9
Comments
Aww man... you lose type safety. I'd rather: |
I was just looking for a solution... I could not found anything working... |
This will also work.. Is the same as @ike18t but with arrow function: |
I can't see the rest of the code. That definitely would cause an error though being that T is not defined to extend anything and you are casting an object with properties declared. |
Basically someone in trying to mock the new HttpClient from Angular 4+ this has a method get< T > which returns Observable<HttpEvent< T >>.
So T has no definition and can't be converted to anything. It does not have to be fixed right away. :D |
Using ts-mocks seems like the wrong tool to use for that job. Angular provides test helpers for mocking out http requests. |
Ha, yes I know.. I also told that ;-). But this triggered me to think about generic methods :D |
When objects have generic methods it is not easy to mock.
For now you must use the following syntax:
mf.setup(f => f.fightersGeneric).Spy.and.returnValue('tada');
or use the spyOf method to use a spy.
But still looking for other solution to be typesafe....
The text was updated successfully, but these errors were encountered: