-
Notifications
You must be signed in to change notification settings - Fork 93
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
autoDetectChanges not automatically detect changes as a "real" running component would do #492
Comments
timdeschryver
added a commit
that referenced
this issue
Oct 14, 2024
The problem is that the following code doesn't assert that that the heading has the name username 2. It's better to use the // assert first username emitted is rendered
expect(await screen.findByRole('heading', { name: 'username 1' })).toBeInTheDocument();
// emitting a second username
user.next({ name: 'username 2' });
// assert the second username is rendered
expect(await screen.findByRole('heading', { name: 'username 2' })).toBeInTheDocument(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue
Reading the documentation of
render
method,autoDetectChanges
option is supposed to take care of the change detection for us.But it seems it is not the case with
Observable
andasync
pipe at least we have to calldetectChanges
manually.Example
Simple user component displaying username resolved from a UserService acting as a store
Testing the username change coming from the service is correctly rendered by the component
component under test :
test :
Expected behavior
As written in the documentation,
autoDetectChanges
should handle changes detection as a real component would dodetectChanges()
method when change detection would naturally occurs in a real browser contextChangeDetectionStrategy
of the component should be taken in accountautoDetectChanges
really run change detection for usThe text was updated successfully, but these errors were encountered: