title: Using marble testing for a function that returns an Observable
body: <p>I have a function that takes an array and returns an Observable (essentially emits each value from the given array after each delay):</p>
  
  <pre><code>export const typewriter = &lt;T&gt;(str: T[], delay = 20) =&gt;
    zip(interval(delay), from(str)).pipe(map(([, str]) =&gt; str));
  </code></pre>
  
  <p>I want to write unit tests for this, and I'm trying to use <a href="https://github.com/cartant/rxjs-marbles" rel="nofollow noreferrer">rxjs-marbles</a> and follow the <a href="https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md" rel="nofollow noreferrer">writing marble tests</a> instructions from RxJS.</p>
  
  <p>All of the examples seem to require a hot source observable and a cold observable for you to compare expected values. In this case I have a function that returns a cold observable. I've tried writing it like this:</p>
  
  <pre><code>const expected = m.hot('-^-a-b-(c|)');
  
  const source = typewriter(['a', 'b', 'c']);
  
  m.expect(source).toBeObservable(expected);
  </code></pre>
  
  <p>However I always get <code>Expected &lt;blank&gt; to equal ...</code>, i.e. the source is blank. I think that this is because the source Observable is not hot, but even if I do
  <code>source.subscribe()</code> before the assertion I get the same error. Using <code>m.cold</code> for the test observable doesn't matter.</p>
  
  <p>How can I test a function that returns an observable using RxJS marbles?</p>