title: Variable always undefined with await Jasmine
body: <p>I need to test a function, and in that function a variable is created and assigned a value.</p>
  <p>But the payload constant is always undefined.</p>
  <p><strong>campaigns-card.component.ts</strong></p>
  <pre><code>async ngOnInit() {
      const { uid } = await this.auth.currentUser
      const { payload } = await this.firestore.surveysUsers(this.survey.id).doc(uid).snapshotChanges().pipe(first()).toPromise();
      this.completed = payload.exists
    }
  </code></pre>
  <p><strong>component-card.component.spec.ts</strong></p>
  <pre><code>beforeEach(waitForAsync(() =&gt; {
      fireStoreServiceMock.surveysUsers.and.returnValue({ 
        doc: () =&gt; { return {
          snapshotChanges: () =&gt; { return {
            pipe: () =&gt; { return {
              toPromise: () =&gt; { return { exists: true }}
            }}
          }}
        }}
      });
    }));
  
  describe('tests in delete', () =&gt; {
      it('should update surveys', fakeAsync(() =&gt; {
        fixture.detectChanges();
        component.delete().then(() =&gt; {
        });
        fixture.detectChanges();
        tick();
  
        expect(fireStoreServiceMock.surveys).toHaveBeenCalled();
        expect(snackBarMock.open).toHaveBeenCalled();
      }));
    });
  </code></pre>
  <p><strong>error</strong></p>
  <pre><code>Error: Uncaught (in promise): TypeError: Cannot read property 'exists' of undefined
  TypeError: Cannot read property 'exists' of undefined
      at CampaignsCardComponent.&lt;anonymous&gt; (http://localhost:9876/_karma_webpack_/webpack:/src/app/modules/campaigns/pages/campaigns-card/campaigns-card.component.ts:43:4)
      at Generator.next (&lt;anonymous&gt;)
      at fulfilled (http://localhost:9876/_karma_webpack_/webpack:/node_modules/tslib/tslib.es6.js:71:42)
      at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:372:1)
      at ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/proxy.js:126:1)
      at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:371:1)
      at Object.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.js:28535:1)
      at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:371:1)
      at Zone.run (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:134:1)
      at http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:1276:1
  </code></pre>