@@ -24,6 +24,7 @@ import {
2424 ɵJSACTION_BLOCK_ELEMENT_MAP as JSACTION_BLOCK_ELEMENT_MAP ,
2525 ɵJSACTION_EVENT_CONTRACT as JSACTION_EVENT_CONTRACT ,
2626 ɵgetDocument as getDocument ,
27+ ɵresetIncrementalHydrationEnabledWarnedForTests as resetIncrementalHydrationEnabledWarnedForTests ,
2728 ɵTimerScheduler as TimerScheduler ,
2829 provideZoneChangeDetection ,
2930} from '@angular/core' ;
@@ -2823,7 +2824,7 @@ describe('platform-server partial hydration integration', () => {
28232824 } ) ;
28242825
28252826 describe ( 'misconfiguration' , ( ) => {
2826- it ( 'should throw an error when `withIncrementalHydration()` is missing in SSR setup' , async ( ) => {
2827+ it ( 'should log a warning when `withIncrementalHydration()` is missing in SSR setup' , async ( ) => {
28272828 @Component ( {
28282829 selector : 'app' ,
28292830 template : `
@@ -2839,17 +2840,15 @@ describe('platform-server partial hydration integration', () => {
28392840
28402841 // Empty list, `withIncrementalHydration()` is not included intentionally.
28412842 const hydrationFeatures = ( ) => [ ] ;
2843+ const consoleSpy = spyOn ( console , 'warn' ) ;
2844+ resetIncrementalHydrationEnabledWarnedForTests ( ) ;
28422845
2843- let producedError ;
2844- try {
2845- await ssr ( SimpleComponent , { envProviders : providers , hydrationFeatures} ) ;
2846- } catch ( error : unknown ) {
2847- producedError = error ;
2848- }
2849- expect ( ( producedError as Error ) . message ) . toContain ( 'NG0508' ) ;
2846+ await ssr ( SimpleComponent , { envProviders : providers , hydrationFeatures} ) ;
2847+ expect ( consoleSpy ) . toHaveBeenCalledTimes ( 1 ) ;
2848+ expect ( consoleSpy ) . toHaveBeenCalledWith ( jasmine . stringMatching ( 'NG0508' ) ) ;
28502849 } ) ;
28512850
2852- it ( 'should throw an error when `withIncrementalHydration()` is missing in hydration setup' , async ( ) => {
2851+ it ( 'should log a warning when `withIncrementalHydration()` is missing in hydration setup' , async ( ) => {
28532852 @Component ( {
28542853 selector : 'app' ,
28552854 template : `
@@ -2872,18 +2871,18 @@ describe('platform-server partial hydration integration', () => {
28722871
28732872 ////////////////////////////////
28742873
2875- let producedError ;
2876- try {
2877- const doc = getDocument ( ) ;
2878- await prepareEnvironmentAndHydrate ( doc , html , SimpleComponent , {
2879- envProviders : [ ... providers , { provide : PLATFORM_ID , useValue : 'browser' } ] ,
2880- // Empty list, `withIncrementalHydration()` is not included intentionally.
2881- hydrationFeatures : ( ) => [ ] ,
2882- } ) ;
2883- } catch ( error : unknown ) {
2884- producedError = error ;
2885- }
2886- expect ( ( producedError as Error ) . message ) . toContain ( 'NG0508' ) ;
2874+ const consoleSpy = spyOn ( console , 'warn' ) ;
2875+ resetIncrementalHydrationEnabledWarnedForTests ( ) ;
2876+
2877+ const doc = getDocument ( ) ;
2878+ await prepareEnvironmentAndHydrate ( doc , html , SimpleComponent , {
2879+ envProviders : [ ... providers , { provide : PLATFORM_ID , useValue : 'browser' } ] ,
2880+ // Empty list, `withIncrementalHydration()` is not included intentionally.
2881+ hydrationFeatures : ( ) => [ ] ,
2882+ } ) ;
2883+
2884+ expect ( consoleSpy ) . toHaveBeenCalledTimes ( 1 ) ;
2885+ expect ( consoleSpy ) . toHaveBeenCalledWith ( jasmine . stringMatching ( 'NG0508' ) ) ;
28872886 } ) ;
28882887 } ) ;
28892888} ) ;
0 commit comments