title: Testing a function that combines Observables
body: <p>I have been tasked with testing observables and I am fairly new to the concept. I have a fair idea of how Observables work, and I need to test a function <code>andCombine</code> that takes two observables and returns the AND result.</p>
  
  <pre><code>  it('tests andCombine', () =&gt; {
         const coldOne = cold('t----f|', {t : true, f : false});
         const coldTwo = cold('t-f|', {t : true, f : false});
         const result = cold('t-f--f|', {t : true, f : false});
         const combined = andCombine(coldOne, coldTwo);
         expect(combined).toBeObservable(result);
  
      });
  </code></pre>
  
  <p>The andCombine looks like </p>
  
  <pre><code>export const andCombine = (...source$: Observable&lt;any&gt;[]): Observable&lt;any&gt; =&gt; {
      return combineLatest(source$.filter(data =&gt; !!data)).pipe(
          map(([...args]: [any[]]) =&gt; {
              return args.reduce((acc, arg) =&gt; {
                  return acc &amp;&amp; !!arg;
              }, true);
          }),
          distinctUntilChanged()
      );
  };
  </code></pre>
  
  <p>And I have the following error logs.</p>
  
  <pre><code>   Error: Expected $.length = 3 to equal 4.
          Expected $[2].frame = 60 to equal 50.
          Expected $[2].notification.kind = 'C' to equal 'N'.
          Expected $[2].notification.value = undefined to equal false.
          Expected $[2].notification.hasValue = false to equal true.
          Expected $[3] = undefined to equal Object({ frame: 60, notification: Notification({ kind: 'C', value: undefined, error: undefined, hasValue: false }) }).
  
  </code></pre>
  
  <p>I know there is something very basic that is missing and I would like someone to help me understand how this thing works and where I'm going wrong</p>