-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Zoneless tests with unset required inputs succeeds unexpectedly #56977
Comments
Take away a doubt from me, in the zone app, the error is thrown when you call |
Yes, see the same repro for the zone app: |
So yeah basically this is same root cause than #56240. In the zone app, it's the In the case of the zoneless test, the CD is fired from an Testing in zoneless apps is a topic in itself that still need some work. You find some details here. |
…oneless tests The behavior of `ComponentFixture` for zoneless tests was decided somewhat through guesswork, trial, and error. In addition, working on the zoneless fixture revealed oddities in the behavior of the zone-based fixture, or behaviors that we felt were counterintuitive. The most consequential difference is how change detection works: `detectChanges` goes through ApplicationRef.tick in zoneless while it is `changeDetectorRef.detectChanges` in the zone fixture. We felt that running change detection through `ApplicationRef.tick` was important for several reasons: * Aligning application behavior more closely with the test behavior (almost all views are attached to application ref in reality) * Ensuring that afterRender* hooks are executed when calling `fixture.detectChanges` * Ensuring that the change detection runs again if render hooks update state This change, however, has some noticeable consequences that will break some tests, mostly around how errors are handled. `ApplicationRef.tick` catches errors that happen during change detection and reports them to the ErrorHandler from DI. The default error handler only logs the error to the console. This will break tests which have `expect(() => fixture.detectChanges()).toThrow()`. In addition, it allows tests to pass when there are real errors encountered during change detection. This change ensures that errors from `ApplicationRef.tick` are rethrown and will fail the test. We should also do a follow-up investigation to determine whether we can/should also do this for the zone-based `ComponentFixture`. fixes angular#56977
…oneless tests The behavior of `ComponentFixture` for zoneless tests was decided somewhat through guesswork, trial, and error. In addition, working on the zoneless fixture revealed oddities in the behavior of the zone-based fixture, or behaviors that we felt were counterintuitive. The most consequential difference is how change detection works: `detectChanges` goes through ApplicationRef.tick in zoneless while it is `changeDetectorRef.detectChanges` in the zone fixture. We felt that running change detection through `ApplicationRef.tick` was important for several reasons: * Aligning application behavior more closely with the test behavior (almost all views are attached to application ref in reality) * Ensuring that afterRender* hooks are executed when calling `fixture.detectChanges` * Ensuring that the change detection runs again if render hooks update state This change, however, has some noticeable consequences that will break some tests, mostly around how errors are handled. `ApplicationRef.tick` catches errors that happen during change detection and reports them to the ErrorHandler from DI. The default error handler only logs the error to the console. This will break tests which have `expect(() => fixture.detectChanges()).toThrow()`. In addition, it allows tests to pass when there are real errors encountered during change detection. This change ensures that errors from `ApplicationRef.tick` are rethrown and will fail the test. We should also do a follow-up investigation to determine whether we can/should also do this for the zone-based `ComponentFixture`. fixes angular#56977
…oneless tests The behavior of `ComponentFixture` for zoneless tests was decided somewhat through guesswork, trial, and error. In addition, working on the zoneless fixture revealed oddities in the behavior of the zone-based fixture, or behaviors that we felt were counterintuitive. The most consequential difference is how change detection works: `detectChanges` goes through ApplicationRef.tick in zoneless while it is `changeDetectorRef.detectChanges` in the zone fixture. We felt that running change detection through `ApplicationRef.tick` was important for several reasons: * Aligning application behavior more closely with the test behavior (almost all views are attached to application ref in reality) * Ensuring that afterRender* hooks are executed when calling `fixture.detectChanges` * Ensuring that the change detection runs again if render hooks update state This change, however, has some noticeable consequences that will break some tests, mostly around how errors are handled. `ApplicationRef.tick` catches errors that happen during change detection and reports them to the ErrorHandler from DI. The default error handler only logs the error to the console. This will break tests which have `expect(() => fixture.detectChanges()).toThrow()`. In addition, it allows tests to pass when there are real errors encountered during change detection. This change ensures that errors from `ApplicationRef.tick` are rethrown and will fail the test. We should also do a follow-up investigation to determine whether we can/should also do this for the zone-based `ComponentFixture`. fixes angular#56977
…oneless tests The behavior of `ComponentFixture` for zoneless tests was decided somewhat through guesswork, trial, and error. In addition, working on the zoneless fixture revealed oddities in the behavior of the zone-based fixture, or behaviors that we felt were counterintuitive. The most consequential difference is how change detection works: `detectChanges` goes through ApplicationRef.tick in zoneless while it is `changeDetectorRef.detectChanges` in the zone fixture. We felt that running change detection through `ApplicationRef.tick` was important for several reasons: * Aligning application behavior more closely with the test behavior (almost all views are attached to application ref in reality) * Ensuring that afterRender* hooks are executed when calling `fixture.detectChanges` * Ensuring that the change detection runs again if render hooks update state This change, however, has some noticeable consequences that will break some tests, mostly around how errors are handled. `ApplicationRef.tick` catches errors that happen during change detection and reports them to the ErrorHandler from DI. The default error handler only logs the error to the console. This will break tests which have `expect(() => fixture.detectChanges()).toThrow()`. In addition, it allows tests to pass when there are real errors encountered during change detection. This change ensures that errors from `ApplicationRef.tick` are rethrown and will fail the test. We should also do a follow-up investigation to determine whether we can/should also do this for the zone-based `ComponentFixture`. fixes angular#56977
…oneless tests The behavior of `ComponentFixture` for zoneless tests was decided somewhat through guesswork, trial, and error. In addition, working on the zoneless fixture revealed oddities in the behavior of the zone-based fixture, or behaviors that we felt were counterintuitive. The most consequential difference is how change detection works: `detectChanges` goes through ApplicationRef.tick in zoneless while it is `changeDetectorRef.detectChanges` in the zone fixture. We felt that running change detection through `ApplicationRef.tick` was important for several reasons: * Aligning application behavior more closely with the test behavior (almost all views are attached to application ref in reality) * Ensuring that afterRender* hooks are executed when calling `fixture.detectChanges` * Ensuring that the change detection runs again if render hooks update state This change, however, has some noticeable consequences that will break some tests, mostly around how errors are handled. `ApplicationRef.tick` catches errors that happen during change detection and reports them to the ErrorHandler from DI. The default error handler only logs the error to the console. This will break tests which have `expect(() => fixture.detectChanges()).toThrow()`. In addition, it allows tests to pass when there are real errors encountered during change detection. This change ensures that errors from `ApplicationRef.tick` are rethrown and will fail the test. We should also do a follow-up investigation to determine whether we can/should also do this for the zone-based `ComponentFixture`. fixes angular#56977
…oneless tests The behavior of `ComponentFixture` for zoneless tests was decided somewhat through guesswork, trial, and error. In addition, working on the zoneless fixture revealed oddities in the behavior of the zone-based fixture, or behaviors that we felt were counterintuitive. The most consequential difference is how change detection works: `detectChanges` goes through ApplicationRef.tick in zoneless while it is `changeDetectorRef.detectChanges` in the zone fixture. We felt that running change detection through `ApplicationRef.tick` was important for several reasons: * Aligning application behavior more closely with the test behavior (almost all views are attached to application ref in reality) * Ensuring that afterRender* hooks are executed when calling `fixture.detectChanges` * Ensuring that the change detection runs again if render hooks update state This change, however, has some noticeable consequences that will break some tests, mostly around how errors are handled. `ApplicationRef.tick` catches errors that happen during change detection and reports them to the ErrorHandler from DI. The default error handler only logs the error to the console. This will break tests which have `expect(() => fixture.detectChanges()).toThrow()`. In addition, it allows tests to pass when there are real errors encountered during change detection. This change ensures that errors from `ApplicationRef.tick` are rethrown and will fail the test. We should also do a follow-up investigation to determine whether we can/should also do this for the zone-based `ComponentFixture`. fixes angular#56977
Which @angular/* package(s) are the source of the bug?
core, zone.js
Is this a regression?
Yes
Description
I am testing a component with (signal based) required inputs. When no value is provided to the required input, it should throw an NG0950 error. With zone change detection it was the case, but when the
provideExperimentalZonelessChangeDetection()
is used, the tests succeeds unexpectedly.After examining the logs I see the NG0950 error logged, but the test still succeeds.
I believe it might be related to #56240
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-pdwsvu?file=src%2Fapp%2Fapp.component.spec.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: