How to test subscription to an Observable – when do I need done() and when must I provide the second parameter to subscribe?

I’m looking at the Testing Services section of the Angular Guide, and I’m confused by some apparent inconsistencies on that page.

At the top, in the very first example it has a sample test like this:

it('#getObservableValue should return value from observable',
  (done: DoneFn) => {
  service.getObservableValue().subscribe(value => {
    expect(value).toBe('observable value');

Notice that it calls done() at the end of the subscribe block.

Later on the same page there are some tests that use a different approach. For example, the very last example on the page has a test like this:

it('should return expected heroes (HttpClient called once)', () => {
  const expectedHeroes: Hero[] =
    [{ id: 1, name: 'A' }, { id: 2, name: 'B' }];


    heroes => expect(heroes).toEqual(expectedHeroes, 'expected heroes'),
  expect(httpClientSpy.get.calls.count()).toBe(1, 'one call');

The first thing that stands out is that this test does not call done().

Secondly, it provides a second parameter (the fail function) to the subscribe call. (I do understand what that parameter is for). It actually calls out in the accompanying text that providing the second parameter is important:

The subscribe() method takes a success (next) and fail (error) callback. Make sure you provide both callbacks so that you capture errors. Neglecting to do so produces an asynchronous uncaught observable error that the test runner will likely attribute to a completely different test.

…which begs the question(s):

  1. Why does the second test not call done(), and
  2. Why does the first test not provide the second parameter to subscribe?

I imagine that there is a "good reason" for both of these things, but it’s not at all obvious to me what that is – and so it’s difficult to know when to use which pattern.

Source: Angular Questions