refactor(testing): remove deprecated test setup functions (#10600)
Remove test setup functions which were deprecated in rc5. See the changelog for rc5 for how to update. In brief, instead of `setBaseTestProviders`, use `TestBed.initTestEnvironment`.
This commit is contained in:

committed by
Alex Rickabaugh

parent
ebcd14f8e9
commit
d75502eeee
@ -6,13 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {CompilerConfig, DirectiveResolver, NgModuleResolver, analyzeAppProvidersForDeprecatedConfiguration} from '@angular/compiler';
|
||||
import {OverridingTestComponentBuilder, platformCoreDynamicTesting} from '@angular/compiler/testing';
|
||||
import {COMPILER_OPTIONS, Compiler, CompilerFactory, NgModule, PlatformRef, Provider, ReflectiveInjector, Type, createPlatform, createPlatformFactory} from '@angular/core';
|
||||
import {TestBed, TestComponentBuilder, TestComponentRenderer} from '@angular/core/testing';
|
||||
import {BrowserTestingModule, platformBrowserTesting} from '@angular/platform-browser/testing';
|
||||
import {NgModule, PlatformRef, createPlatformFactory} from '@angular/core';
|
||||
import {TestComponentBuilder, TestComponentRenderer} from '@angular/core/testing';
|
||||
import {BrowserTestingModule} from '@angular/platform-browser/testing';
|
||||
|
||||
import {Console} from './core_private';
|
||||
import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './src/platform_providers';
|
||||
import {DOMTestComponentRenderer} from './testing/dom_test_component_renderer';
|
||||
|
||||
@ -39,36 +37,3 @@ export const platformBrowserDynamicTesting = createPlatformFactory(
|
||||
})
|
||||
export class BrowserDynamicTestingModule {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use initTestEnvironment with platformBrowserDynamicTesting instead.
|
||||
*/
|
||||
export const TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
// Note: This is not a real provider but a hack to still support the deprecated
|
||||
// `setBaseTestProviders` method!
|
||||
[(appProviders: any[]) => {
|
||||
const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(appProviders);
|
||||
const platformRef =
|
||||
createPlatformFactory(platformBrowserDynamicTesting, 'browserDynamicTestingDeprecated', [{
|
||||
provide: COMPILER_OPTIONS,
|
||||
useValue: deprecatedConfiguration.compilerOptions,
|
||||
multi: true
|
||||
}])();
|
||||
|
||||
@NgModule({
|
||||
exports: [BrowserDynamicTestingModule],
|
||||
declarations: [deprecatedConfiguration.moduleDeclarations]
|
||||
})
|
||||
class DynamicTestModule {
|
||||
}
|
||||
|
||||
const testInjector = TestBed.initTestEnvironment(DynamicTestModule, platformRef);
|
||||
const console: Console = testInjector.get(Console);
|
||||
deprecatedConfiguration.deprecationMessages.forEach((msg) => console.warn(msg));
|
||||
}];
|
||||
|
||||
/**
|
||||
* @deprecated Use initTestEnvironment with BrowserDynamicTestingModule instead.
|
||||
*/
|
||||
export const TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[];
|
||||
|
Reference in New Issue
Block a user