Skip to content

Migration doesn’t add provideZoneChangeDetection() to tests #65941

@mwaibel-go

Description

@mwaibel-go

Describe the problem that you experienced

This issue is somewhere between a bug, documentation issue and feature request. I’m unsure where to put it.

The Angular update guide contains the step (emphasis mine)

Zone-based applications should add provideZoneChangeDetection() to your application's root providers. For standalone apps, add it to the bootstrapApplication call. For NgModule-based apps, add it to your root AppModule's providers array. An automated migration should handle this.

While the migration does update the main app, it leaves the tests alone, which in my case caused them to fail with an ExpressionChangedAfterItHasBeenCheckedError that was very hard to find the root cause for.

Enter the URL of the topic with the problem

https://angular.dev/update-guide?v=20.0-21.0&l=1

Describe what you were looking for in the documentation

It would be nice if the migration could add the provider to the TestBed.configureTestingModule calls automatically. Alternatively it would be nice if the upgrade step mentioned manually updating the tests and where to put the provideZoneChangeDetection() call.

Describe the actions that led you to experience the problem

Upgrading Angular from v20 to v21 and running the tests.

Describe what you want to experience that would fix the problem

No response

Add a screenshot if that helps illustrate the problem

No response

If this problem caused an exception or error, please paste it here

error properties: Object({ code: -100 })
    at throwErrorIfNoChangesMode (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:3472:9)
    at bindingUpdated (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:7915:9)
    at ɵɵconditional (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:14018:7)
    at OrganizationalUnitDetailsComponent2_Conditional_2_Template (ng:///OrganizationalUnitDetailsComponent2.js:288:5)
    at executeTemplate (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:4831:5)
    at refreshView (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:5501:7)
    at detectChangesInView (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:5641:5)
    at detectChangesInViewIfAttached (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:5624:3)
    at detectChangesInEmbeddedViews (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:5595:7)
    at refreshView (http://localhost:9876/base/node_modules/@angular/core/fesm2022/_debug_node-chunk.mjs:5522:5)

If the problem is browser-specific, please specify the device, OS, browser, and version


Provide any additional information here in as much as detail as you can


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions