angular/packages/core/testing/src
Andrew Scott 468d3fb9b1 fix(core): rethrow errors during ApplicationRef.tick in TestBed (#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 Close #57200
2024-08-12 11:23:46 -07:00
..
application_error_handler.ts fix(core): rethrow errors during ApplicationRef.tick in TestBed (#57200) 2024-08-12 11:23:46 -07:00
async.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
component_fixture.ts feat(core): Add whenStable helper on ApplicationRef (#57190) 2024-08-06 21:28:16 +00:00
defer.ts refactor(core): mark @defer APIs as stable (#55625) 2024-05-02 14:42:00 -07:00
fake_async.ts feat(core): Add 'flush' parameter option to fakeAsync to flush after the test (#57239) 2024-08-05 17:46:04 +00:00
logger.ts refactor(core): cleanup type any (#48623) 2023-01-04 12:15:16 -08:00
metadata_override.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
metadata_overrider.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
resolvers.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
styling.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
test_bed.ts refactor(core): clean up clang comments and workarounds (#55750) 2024-05-13 11:10:36 -07:00
test_bed_common.ts fix(core): rethrow errors during ApplicationRef.tick in TestBed (#57200) 2024-08-12 11:23:46 -07:00
test_bed_compiler.ts fix(core): rethrow errors during ApplicationRef.tick in TestBed (#57200) 2024-08-12 11:23:46 -07:00
test_hooks.ts fix(core): test cleanup should not throw if Zone is not present (#55096) 2024-03-28 12:12:30 -07:00
testing.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
testing_internal.ts refactor(core): Remove ununsed Zone mock from testing internals. (#49873) 2023-04-18 14:00:15 +00:00