refactor(platform-browser-dynamic): relocate DOMTestComponentRenderer to @angular/platform-browser (#60453)

This commit moves `DOMTestComponentRenderer` to `@angular/platform-browser/testing`, allowing the Angular CLI to eliminate its dependency on `@angular/platform-browser-dynamic`, which would no longer be required for new projects.

PR Close #60453
This commit is contained in:
Alan Agius
2025-03-19 10:45:38 +00:00
committed by Pawel Kozlowski
parent 29eded6457
commit 5753aa70eb
9 changed files with 21 additions and 11 deletions
@@ -989,7 +989,7 @@ export class TestBedCompiler {
}
const providers: StaticProvider[] = [];
const compilerOptions = this.platform.injector.get(COMPILER_OPTIONS);
const compilerOptions = this.platform.injector.get(COMPILER_OPTIONS, []);
compilerOptions.forEach((opts) => {
if (opts.providers) {
providers.push(opts.providers);
@@ -6,5 +6,5 @@
* found in the LICENSE file at https://angular.dev/license
*/
export {DOMTestComponentRenderer as ɵDOMTestComponentRenderer} from './dom_test_component_renderer';
export {platformCoreDynamicTesting as ɵplatformCoreDynamicTesting} from './platform_core_dynamic_testing';
export {ɵDOMTestComponentRenderer} from '@angular/platform-browser/testing';
@@ -7,11 +7,9 @@
*/
import {createPlatformFactory, NgModule, PlatformRef, StaticProvider} from '@angular/core';
import {TestComponentRenderer} from '@angular/core/testing';
import {ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from '@angular/platform-browser-dynamic';
import {BrowserTestingModule} from '@angular/platform-browser/testing';
import {DOMTestComponentRenderer} from './dom_test_component_renderer';
import {platformCoreDynamicTesting} from './platform_core_dynamic_testing';
export * from './private_export_testing';
@@ -32,6 +30,5 @@ export const platformBrowserDynamicTesting = createPlatformFactory(
*/
@NgModule({
exports: [BrowserTestingModule],
providers: [{provide: TestComponentRenderer, useClass: DOMTestComponentRenderer}],
})
export class BrowserDynamicTestingModule {}
@@ -18,7 +18,9 @@ import {
ɵChangeDetectionScheduler as ChangeDetectionScheduler,
ɵChangeDetectionSchedulerImpl as ChangeDetectionSchedulerImpl,
} from '@angular/core';
import {TestComponentRenderer} from '@angular/core/testing';
import {BrowserModule, ɵBrowserDomAdapter as BrowserDomAdapter} from '@angular/platform-browser';
import {DOMTestComponentRenderer} from './dom_test_component_renderer';
function initBrowserTests() {
BrowserDomAdapter.makeCurrent();
@@ -51,6 +53,7 @@ export const platformBrowserTesting = createPlatformFactory(
internalProvideZoneChangeDetection({}),
{provide: ChangeDetectionScheduler, useExisting: ChangeDetectionSchedulerImpl},
{provide: PlatformLocation, useClass: MockPlatformLocation},
{provide: TestComponentRenderer, useClass: DOMTestComponentRenderer},
],
})
export class BrowserTestingModule {}
@@ -0,0 +1,9 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export {DOMTestComponentRenderer as ɵDOMTestComponentRenderer} from './dom_test_component_renderer';
@@ -12,3 +12,4 @@
* Entry point for all public APIs of the platform-browser/testing package.
*/
export * from './browser';
export * from './private_export_testing';