build: Run browsers tests without platform-browser-dynamic (#60937)

Use the regular `platform-browser` providers instead.

PR Close #60937
This commit is contained in:
Matthieu Riegler
2025-04-21 21:13:58 +02:00
committed by Miles Malerba
parent b250bb0a74
commit b896ca8ed5
7 changed files with 49 additions and 48 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ ts_library(
"//packages/core/testing",
"//packages/localize/init",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/platform-browser-dynamic/testing",
"//packages/platform-browser/animations",
"//packages/platform-browser/testing",
"//packages/platform-server",
+19 -27
View File
@@ -15,7 +15,6 @@ import {
Compiler,
CompilerFactory,
Component,
effect,
EnvironmentInjector,
InjectionToken,
Injector,
@@ -23,7 +22,6 @@ import {
NgModule,
NgZone,
PlatformRef,
ProviderToken,
provideZoneChangeDetection,
RendererFactory2,
TemplateRef,
@@ -48,6 +46,7 @@ import {ApplicationRef} from '../src/application/application_ref';
import {NoopNgZone} from '../src/zone/ng_zone';
import {ComponentFixtureNoNgZone, inject, TestBed, waitForAsync, withModule} from '../testing';
import {take} from 'rxjs/operators';
import {compileNgModuleFactory} from '../src/application/application_ngmodule_factory_compiler';
let serverPlatformModule: Promise<Type<ServerModule>> | null = null;
if (isNode) {
@@ -677,30 +676,27 @@ describe('bootstrap', () => {
initializerDone = true;
}, 1);
const compilerFactory: CompilerFactory = defaultPlatform.injector.get(CompilerFactory, null)!;
const moduleFactory = compilerFactory
.createCompiler()
.compileModuleSync(
await createModule([{provide: APP_INITIALIZER, useValue: () => promise, multi: true}]),
);
const moduleType = await createModule([
{provide: APP_INITIALIZER, useValue: () => promise, multi: true},
]);
const moduleFactory = await compileNgModuleFactory(defaultPlatform.injector, {}, moduleType);
defaultPlatform.bootstrapModuleFactory(moduleFactory).then((_) => {
expect(initializerDone).toBe(true);
});
}));
it('should rethrow sync errors even if the exceptionHandler is not rethrowing', waitForAsync(async () => {
const compilerFactory: CompilerFactory = defaultPlatform.injector.get(CompilerFactory, null)!;
const moduleFactory = compilerFactory.createCompiler().compileModuleSync(
await createModule([
{
provide: APP_INITIALIZER,
useValue: () => {
throw 'Test';
},
multi: true,
const moduleType = await createModule([
{
provide: APP_INITIALIZER,
useValue: () => {
throw 'Test';
},
]),
);
multi: true,
},
]);
const moduleFactory = await compileNgModuleFactory(defaultPlatform.injector, {}, moduleType);
expect(() => defaultPlatform.bootstrapModuleFactory(moduleFactory)).toThrow('Test');
// Error rethrown will be seen by the exception handler since it's after
// construction.
@@ -708,14 +704,10 @@ describe('bootstrap', () => {
}));
it('should rethrow promise errors even if the exceptionHandler is not rethrowing', waitForAsync(async () => {
const compilerFactory: CompilerFactory = defaultPlatform.injector.get(CompilerFactory, null)!;
const moduleFactory = compilerFactory
.createCompiler()
.compileModuleSync(
await createModule([
{provide: APP_INITIALIZER, useValue: () => Promise.reject('Test'), multi: true},
]),
);
const moduleType = await createModule([
{provide: APP_INITIALIZER, useValue: () => Promise.reject('Test'), multi: true},
]);
const moduleFactory = await compileNgModuleFactory(defaultPlatform.injector, {}, moduleType);
defaultPlatform.bootstrapModuleFactory(moduleFactory).then(
() => expect(false).toBe(true),
(e) => {
@@ -36,8 +36,7 @@ import {
ViewContainerRef,
} from '../../src/core';
import {fakeAsync, inject, TestBed, tick} from '../../testing';
import {BrowserModule, By} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {BrowserModule, By, platformBrowser} from '@angular/platform-browser';
import {expect} from '@angular/platform-browser/testing/src/matchers';
describe('regressions', () => {
@@ -485,7 +484,7 @@ describe('regressions using bootstrap', () => {
})
class TestModule {}
platformBrowserDynamic()
platformBrowser()
.bootstrapModule(TestModule)
.then((ref) => {
NgZone.assertNotInAngularZone();