Does fakeAsync guarantee promise completion after tick/flushMicroservice

后端 未结 2 1252
日久生厌
日久生厌 2020-11-30 12:46

Main issue is how to test that expected actions were performed once a Promise was completed, for example to test if a component correctly updates its states after receiving

2条回答
  •  醉酒成梦
    2020-11-30 13:26

    So yes, as Thierry explained in his answer fakeAsync allows testing synchronously the business logic behind handling promises.

    I just wanted to add, that the test for fakeAsync have even specs for promise related scenarios:

    describe('Promise', () => {
          it('should run asynchronous code', fakeAsync(() => {
    ...
          it('should run chained thens', fakeAsync(() => {
    ...
          it('should run Promise created in Promise', fakeAsync(() => {
    

    I found those tests at: https://github.com/angular/angular/blob/master/packages/core/test/fake_async_spec.ts

提交回复
热议问题