question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Testing with readFirst] Observable type error on nx version 15.0.6 and above

See original GitHub issue

Hi,

I have an angular application and am currently on nx version 15.0.5 with rxjs version 7.5.6 and have the problem that the unit test fail when I update to all the newer patch versions.

Current Behavior

The unit test fail on the readFirst, as it seems that the Observable import is not the same as the Observable import of rxjs, which confuses me. The exact error:

Argument of type ‘import(“/…/node_modules/rxjs/dist/types/internal/Observable”).Observable<boolean>’ is not assignable to parameter of type ‘import(“/…/node_modules/@nrwl/angular/node_modules/rxjs/internal/Observable”).Observable<boolean>’.

Type ‘Observable<boolean>’ is missing the following properties from type ‘Observable<boolean>’: _isScalar, _trySubscribe, _subscribe

Expected Behavior

No type error, unit test succeeds just like in nx version 15.0.5.

Steps to Reproduce

Use readFirst for a unit test in nx version 15.0.6 or above.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sjimenez77commented, Dec 15, 2022

Yes, you are right @Coly010! I forgot completely the firstValueFrom operator 😄. I think that I will replace it everywhere.

1reaction
Coly010commented, Dec 15, 2022

You might be able to use the firstValueFrom operator from RxJS itself https://rxjs.dev/api/index/function/firstValueFrom

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing error case with observables in services - Stack Overflow
The subscribe call takes two anonymous functions as parameters, I've managed to set up a working unit test for the data function but...
Read more >
Pulse · nrwl/nx · GitHub
Contribute to nrwl/nx development by creating an account on GitHub. ... [Testing with readFirst] Observable type error on nx version 15.0.6 and above....
Read more >
Using observables to pass values - Angular
Use the Observable constructor to create an observable stream of any type. The constructor takes as its argument the subscriber function to run...
Read more >
How to test Observables. The ultimate guide - Medium
The ultimate guide — never again be confused on how to test Observables ... We need to remember that the values are emitted...
Read more >
Angular Tutorial - Testing in NgRx Effects - NgServe.io
hot('-------a', { a: { type: '[Customers API] Search Customers Success', customers: [...], }, });. In the code above, the hot observable ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found