title: How to spyon an observable property
body: <p>I would like to unit test an Angular 10 component. In the component's ngOnInit method, this code appears:</p>
  <pre><code>this.subscriptions.push(
     this.myService.getDataSubject.subscribe((results) =&gt; {
        this.data = results;
     }
  );
  </code></pre>
  <p>Also, in the unit test</p>
  <pre><code>beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
          providers: [MyService]
      }).compileComponents();
  })
  </code></pre>
  <p>My unit test includes</p>
  <pre><code>beforeEach(() =&gt; {
      spyOnProperty(myService, 'getDataSubject', 'get').and.returnValue(of(mockData));
  }
  </code></pre>
  <p>In the service itself</p>
  <pre><code>private dataSubject: BehaviorSubject&lt;any&gt; = new BehaviorSubject({});
  getDataSubject = this.dataSubject.asObservable();
  </code></pre>
  <p>The unit test fails. I've tried multiple variations but cannot get the mockData value to be returned. When writing a unit test for a component that subscribes to a property tied to a BehaviorSubject, what am I supposed to do?</p>