fix(core): remove deprecated TestBed.deprecatedOverrideProvider API (#30576)

BREAKING CHANGE

In PR #19558, we fixed a bug in `TestBed.overrideProvider` where
eager providers were not being instantiated correctly. However,
it turned out that since this bug had been around for quite a bit,
many apps were relying on the broken behavior where the providers
would not be instantiated. To assist in the transition, the
`TestBed.deprecatedOverrideProvider` method was temporarily
introduced to mimic the old behavior so that apps would have a
longer time period to migrate their code.

2 years and 3 versions later, it is time to remove the temporary
method. This commit removes `TestBed.deprecatedOverrideProvider`
altogether. Any usages of `TestBed.deprecatedOverrideProvider`
should be replaced with `TestBed.overrideProvider`. This may mean
that providers that were not created before will now be instantiated,
which could mean that your tests need to provide more mocks or stubs
for the dependencies of the newly instantiated providers.

PR Close #30576
This commit is contained in:
Kara Erickson
2019-05-20 16:08:16 -07:00
committed by Jason Aden
parent ebfbc04000
commit a96976e88f
6 changed files with 12 additions and 169 deletions

View File

@ -494,27 +494,6 @@ class CompWithUrlTemplate {
expect(someModule).toBeAnInstanceOf(SomeModule);
});
obsoleteInIvy(`deprecated method, won't be reimplemented for Render3`)
.it('should keep imported NgModules lazy with deprecatedOverrideProvider', () => {
let someModule: SomeModule|undefined;
@NgModule()
class SomeModule {
constructor() { someModule = this; }
}
TestBed.configureTestingModule({
providers: [
{provide: 'a', useValue: 'aValue'},
],
imports: [SomeModule]
});
TestBed.deprecatedOverrideProvider('a', {useValue: 'mockValue'});
expect(TestBed.get('a')).toBe('mockValue');
expect(someModule).toBeUndefined();
});
describe('injecting eager providers into an eager overwritten provider', () => {
@NgModule({
providers: [