You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): rethrow errors during ApplicationRef.tick in TestBed (angular#57200)
Errors during change detection from `ApplicationRef.tick` are only reported to the `ErrorHandler`. By default, this only logs the error to console. As a result, these errors can be missed/ignored and allow tests to pass when they should not. This change ensures that the errors are surfaced. Note that this is already the behavior when zoneless is enabled. BREAKING CHANGE: Errors that are thrown during `ApplicationRef.tick` will now be rethrown when using `TestBed`. These errors should be resolved by ensuring the test environment is set up correctly to complete change detection successfully. There are two alternatives to catch the errors: * Instead of waiting for automatic change detection to happen, trigger it synchronously and expect the error. For example, a jasmine test could write `expect(() => TestBed.inject(ApplicationRef).tick()).toThrow()` * `TestBed` will reject any outstanding `ComponentFixture.whenStable` promises. A jasmine test, for example, could write `expectAsync(fixture.whenStable()).toBeRejected()`. As a last resort, you can configure errors to _not_ be rethrown by setting `rethrowApplicationErrors` to `false` in `TestBed.configureTestingModule`. PR Closeangular#57200
0 commit comments