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.

Initial value test with BehaviorSubject fails

See original GitHub issue

Hi,

I have been trying to use jasmine-marbles in an Angular project but the following test is failing:

it('works', () => {
  const foo = new BehaviorSubject(1);
  const expected = cold('a', { a: 1 });
  
  expect(foo).toBeObservable(expected);
});

The error is as follows:

Error:
    Expected: a,
    Received: ?,

    Expected:
    [{"frame":0,"notification":{"kind":"N","value":1,"hasValue":true}}]

    Received:
    [{"frame":0,"notification":{"kind":"N","value":1}}],

The same test using TestScheduler as follows works:

const foo = new BehaviorSubject(1);

scheduler.run((helpers) => {
  helpers.expectObservable(foo).toBe('a', { a: 1 });
});

Any suggestions?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sorubancommented, Jul 23, 2021

@qdelettre My bad, I confirm this works fine when downgrading to 0.8.3.

0reactions
qdelettrecommented, Jul 23, 2021

0.2.0 supports RxJS 5.x => 0.3.* supports RxJS 6.x => 0.9.0 supports RxJS 7.x

You cannot use 0.9.0 with rxjs < 7

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJS BehaviorSubject getValue inconsistency after value ...
getValue() returns the default value of the Observable and not the last value emitted. When testing the Observable, it correctly returns the ...
Read more >
Testing of BehaviorSubject with seed or first null value #170
I can't seem to test properly that BehaviorSubject emits null value first, either with add method or with seed value.
Read more >
Angular Unit Testing BehaviorSubject Karma Jamsine
Then you need to trigger the behavior subject with a value and validate the same value in the data variable in component.
Read more >
Testing Components depending on Services - Testing Angular
We declare a variable fakeCount$ in the scope of the test suite and assign a BehaviorSubject in the first beforeEach block: describe(' ...
Read more >
Understanding rxjs BehaviorSubject, ReplaySubject and ...
We first create a subject and subscribe to that with Subscriber A. The Subject then emits it's value and Subscriber A will log...
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