Skip to content

Change detection should run automatically after router navigation in unit tests #48608

@antischematic

Description

@antischematic

Which @angular/* package(s) are the source of the bug?

core, router

Is this a regression?

No

Description

Given a component fixture is set to autoDetectChanges and I call router.navigate, router outlets should emit activate events and render the outlet component, but they don't. As a result of #46554 I must manually call detectChanges after every navigation to ensure the view is up to date.

When serving the app everything works fine without needing to perform manual change detection. It only happens in unit tests.

Please provide a link to a minimal reproduction of the bug

https://github.com/antischematic/angular-15-router-event-defect/blob/master/src/app/route-extension.spec.ts

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 15.0.4
Node: 16.13.0
Package Manager: npm 8.1.0
OS: darwin x64

Angular: 15.0.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.4
@angular-devkit/build-angular   15.0.4
@angular-devkit/core            15.0.4
@angular-devkit/schematics      15.0.4
@schematics/angular             15.0.4
rxjs                            7.5.7
typescript                      4.8.4

Anything else?

These tests were passing in Angular 14 without calling fixture.detectChanges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testingIssues related to Angular testing features, such as TestBedfeatureIssue that requests a new featurestate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions