c8f056beb6
There is an inconsistency in overrideProvider behaviour. Testing documentation says (https://angular.io/guide/testing-components-basics#createcomponent) that all override... methods throw error if TestBed is already instantiated. However overrideProvider doesn't throw any error, but (same as other override... methods) doesn't replace providers if TestBed is instantiated. Add TestBed instantiation check to overrideProvider method to make it consistent. BREAKING CHANGE: If you call `TestBed.overrideProvider` after TestBed initialization, provider overrides are not applied. This behavior is consistent with other override methods (such as `TestBed.overrideDirective`, etc) but they throw an error to indicate that, when the check was missing in the `TestBed.overrideProvider` function. Now calling `TestBed.overrideProvider` after TestBed initialization also triggers an error, thus there is a chance that some tests (where `TestBed.overrideProvider` is called after TestBed initialization) will start to fail and require updates to move `TestBed.overrideProvider` calls before TestBed initialization is completed. Issue mentioned here: https://github.com/angular/angular/issues/13460#issuecomment-636005966 Documentation: https://angular.io/guide/testing-components-basics#createcomponent PR Close #38717 |
||
---|---|---|
.. | ||
browser | ||
dom | ||
security | ||
static_assets | ||
BUILD.bazel | ||
browser_util_spec.ts | ||
testing_public_spec.ts |