-
Notifications
You must be signed in to change notification settings - Fork 9
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
Using spy on a TS > 4.3.x project causes CombineLatest ref to be function instead of Observable #15
Comments
For reference, previous discussions relating to this issue can be found starting with this comment. |
@pauleustice --> |
@LironHazan Cool! I've added some logging into Mocker.prototype.processProperties:
When it iterates over the class fields on ExampleService, the following happens:
That's why the stub is being added. Now we need to work out what the difference in TS version is, that means the EDIT: To clarify, with TS 4.3.5 the log is:
And as such, it does not get stubbed. |
@LironHazan I haven't had a chance to do too much more on this, but I've just attempted to isolate the issue further by using ts-mockito outside of Jest. I created a basic TS file, which behaves as expected:
This suggests to me that it isn't Typescript / ts-mockito exclusively, more like Jest, ts-jest or something else... 🤔 |
@pauleustice Interesting and a different angle than what I thought,
This is the transpiled code as string when running version > 4.3.x And for 4.3.5 its:
I tried to fix the "functionNameRegex" but that didn't work, |
@pauleustice btw I tried running with karma instead and still fails for same reason, |
Interesting... so it's probably not Jest then! So in your examples above, did MockableFunctionsFinder not show up the |
@pauleusticeI it seems like my debugger was out of sync! |
Oh wow, amazing work! Let me know if I can help, I can make some time tomorrow! |
I fixed it in my fork: johanblumenberg@08979c2 I opened a PR to try to fix it in this repository as well, but it wasn't straightforward. See details in #17. |
@pauleustice I started to resolve it using a parser #17 (comment) but I want to try to merge @johanblumenberg PR instead |
@pauleustice
Thinking out load:
With TS 4.4.x following line fails:
service.combinedProviderObservable$.subscribe((value)
TypeError: service.combinedProviderObservable$.subscribe is not a function
I've printed the service for 4.4.x and got:
'**combinedProviderObservable$**': [Function (anonymous)],
And for 4.3.x we get:
When removing the use of spy it works in 4.4.x,
In TS 4.4.x: When using spy CombineLatest returns a function ref and without the spy the CombineLatest returns an observable.
Won't happen in TS 4.3.x
Wow I don't have a clue,
I'm unfamiliar as well with the spy related code, but what I can do in this repo is adding the test with rxjs that would fail and then we can debug on ts-mockito source
The text was updated successfully, but these errors were encountered: