Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): ComponentFixture autoDetect feature works like production #55228

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Apr 5, 2024

This commit fully integrates the autoDetect feature into ApplicationRef.tick without special handling for errors.

BREAKING CHANGE: The autoDetect feature of ComponentFixture will now report errors to the ErrorHandler. Previously, these errors were thrown in a setTimeout. The default behavior of ErrorHandler is to simply log the error to console. This change may cause custom error handlers to observe new failures that were previously unreported.

@atscott atscott added the target: major This PR is targeted for the next major release label Apr 5, 2024
@angular-robot angular-robot bot added the detected: breaking change PR contains a commit with a breaking change label Apr 5, 2024
@atscott atscott force-pushed the componentfixtureautodetect_saneVersion branch 2 times, most recently from e7739f3 to d1b1e6c Compare April 5, 2024 22:46
This commit fully integrates the `autoDetect` feature into
`ApplicationRef.tick` without special handling for errors.

BREAKING CHANGE: The `autoDetect` feature of `ComponentFixture` will now
report errors to the `ErrorHandler`. Previously, these errors were
thrown in a `setTimeout`. The default behavior of `ErrorHandler` is to
simply log the error to console. This change may cause custom error
handlers to observe new failures that were previously unreported.
Tests which use `fakeAsync` and call `flush` to expect these errors in
`setTimeout` to be thrown synchronously will also need to provide an
`ErrorHandler` that rethrows the errors:
```
{
  provide: ErrorHandler,
  useValue: {
    handleError(e: unknown) {
      throw e;
    },
  },
};
```
@atscott atscott force-pushed the componentfixtureautodetect_saneVersion branch 2 times, most recently from 61c7250 to 7ce2963 Compare April 6, 2024 15:05
This commit shares the method of autoDetect for change detection between
the zoneless and zone component fixture implementations. The difference
is now limited to:

* autoDetect is not optional with zoneless
* detectChanges with zoneless is AppRef.tick while it is
  ChangeDetectorRef.detectChanges with zones. This should likely
  converge more in the future. Not going through AppRef.tick means that
  the zone fixture does not get guaranteed `afterRender` executions and
  does not get the rerunning behavior if the fixture is marked dirty by
  a render hook.
@pkozlowski-opensource pkozlowski-opensource added the area: core Issues related to the framework runtime label Apr 11, 2024
@ngbot ngbot bot added this to the Backlog milestone Apr 11, 2024
@atscott atscott marked this pull request as draft April 12, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime detected: breaking change PR contains a commit with a breaking change target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants