Angular 测试时未定义MicroTaskEmpty上的角度区域

Angular 测试时未定义MicroTaskEmpty上的角度区域,angular,Angular,我有以下试验台: TestBed.configureTestingModule({ imports: [ReactiveFormsModule, MaterialModules, RouterTestingModule], declarations: [SigninComponent, LoaderComponent], providers: [ MatSnackBar, { provide: Router, useClass: RouterTestingModu

我有以下试验台:

TestBed.configureTestingModule({
  imports: [ReactiveFormsModule, MaterialModules, RouterTestingModule],
  declarations: [SigninComponent, LoaderComponent],
  providers: [
    MatSnackBar, {
      provide: Router, useClass: RouterTestingModule
    }, {
      provide: ActivatedRoute, useValue: {
        snapshot: { params: Observable.of({ email: 'test@bizanalyst.in' }) }
      }
    }, {
      provide: NgZone, useValue: mockNgZone
    },
    LoaderService,
    FormBuilder,
    StoreOperationService
  ]
}).compileComponents()
此测试抛出一个错误:

it('should have a defined component', () => {
  expect(component).toBeNull(false)
})
错误是:

TypeError: Cannot read property 'subscribe' of undefined
    at new ApplicationRef_ (webpack:///node_modules/@angular/core/@angular/core.es5.js:4684:0 <- config/spec-bundle.js:5351:37)
    at _createClass (webpack:///node_modules/@angular/core/@angular/core.es5.js:9539:0 <- config/spec-bundle.js:10206:20)
    at _createProviderInstance$1 (webpack:///node_modules/@angular/core/@angular/core.es5.js:9503:0 <- config/spec-bundle.js:10170:26)
    at initNgModule (webpack:///node_modules/@angular/core/@angular/core.es5.js:9456:0 <- config/spec-bundle.js:10123:28)

只需从测试模块依赖项中删除
provide:NgZone,useValue:mockNgZone
。没有必要在茉莉花中使用它。只需跳过提供者列表中NgZone的声明

 _this._zone.onMicrotaskEmpty.subscribe({ next: function () { _this._zone.run(function () { _this.tick(); }); } });