feat(core): rethrow errors during ApplicationRef.tick in TestBed#57200
Closed
atscott wants to merge 1 commit into
Closed
feat(core): rethrow errors during ApplicationRef.tick in TestBed#57200atscott wants to merge 1 commit into
atscott wants to merge 1 commit into
Conversation
4a5b5a0 to
d37f8b0
Compare
AndrewKushnir
approved these changes
Jul 31, 2024
Contributor
AndrewKushnir
left a comment
There was a problem hiding this comment.
LGTM, just one minor comment.
57123fe to
714cdfc
Compare
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`.
714cdfc to
cf7f761
Compare
Contributor
Author
Contributor
Author
|
caretaker note: This will need an update to catalyst since the private option is renamed and made public: cl/660852548 |
AndrewKushnir
approved these changes
Aug 12, 2024
AndrewKushnir
approved these changes
Aug 12, 2024
Contributor
AndrewKushnir
left a comment
There was a problem hiding this comment.
Reviewed-for: public-api
thePunderWoman
approved these changes
Aug 12, 2024
Contributor
thePunderWoman
left a comment
There was a problem hiding this comment.
reviewed-for: public-api
Contributor
|
This PR was merged into the repository by commit 468d3fb. The changes were merged into the following branches: main |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Errors during change detection from
ApplicationRef.tickare onlyreported to the
ErrorHandler. By default, this only logs the error toconsole. 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.
The rethrowing behavior will be the default in v19.
BREAKING CHANGE: Errors that are thrown during
ApplicationRef.tickwill now be rethrown when using
TestBed. These errors should beresolved by ensuring the test environment is set up correctly to
complete change detection successfully. There are two alternatives to
catch the errors:
it synchronously and expect the error. For example, a jasmine test
could write
expect(() => TestBed.inject(ApplicationRef).tick()).toThrow()TestBedwill reject any outstandingComponentFixture.whenStablepromises. 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
rethrowApplicationErrorstofalseinTestBed.configureTestingModule.