@@ -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' ;
@@ -2870,7 +2871,7 @@ describe('platform-server partial hydration integration', () => {
28702871 } ) ;
28712872
28722873 describe ( 'misconfiguration' , ( ) => {
2873- it ( 'should throw an error when `withIncrementalHydration()` is missing in SSR setup' , async ( ) => {
2874+ it ( 'should log a warning when `withIncrementalHydration()` is missing in SSR setup' , async ( ) => {
28742875 @Component ( {
28752876 selector : 'app' ,
28762877 template : `
@@ -2886,17 +2887,15 @@ describe('platform-server partial hydration integration', () => {
28862887
28872888 // Empty list, `withIncrementalHydration()` is not included intentionally.
28882889 const hydrationFeatures = ( ) => [ ] ;
2890+ const consoleSpy = spyOn ( console , 'warn' ) ;
2891+ resetIncrementalHydrationEnabledWarnedForTests ( ) ;
28892892
2890- let producedError ;
2891- try {
2892- await ssr ( SimpleComponent , { envProviders : providers , hydrationFeatures} ) ;
2893- } catch ( error : unknown ) {
2894- producedError = error ;
2895- }
2896- expect ( ( producedError as Error ) . message ) . toContain ( 'NG0508' ) ;
2893+ await ssr ( SimpleComponent , { envProviders : providers , hydrationFeatures} ) ;
2894+ expect ( consoleSpy ) . toHaveBeenCalledTimes ( 1 ) ;
2895+ expect ( consoleSpy ) . toHaveBeenCalledWith ( jasmine . stringMatching ( 'NG0508' ) ) ;
28972896 } ) ;
28982897
2899- it ( 'should throw an error when `withIncrementalHydration()` is missing in hydration setup' , async ( ) => {
2898+ it ( 'should log a warning when `withIncrementalHydration()` is missing in hydration setup' , async ( ) => {
29002899 @Component ( {
29012900 selector : 'app' ,
29022901 template : `
@@ -2919,18 +2918,18 @@ describe('platform-server partial hydration integration', () => {
29192918
29202919 ////////////////////////////////
29212920
2922- let producedError ;
2923- try {
2924- const doc = getDocument ( ) ;
2925- await prepareEnvironmentAndHydrate ( doc , html , SimpleComponent , {
2926- envProviders : [ ... providers , { provide : PLATFORM_ID , useValue : 'browser' } ] ,
2927- // Empty list, `withIncrementalHydration()` is not included intentionally.
2928- hydrationFeatures : ( ) => [ ] ,
2929- } ) ;
2930- } catch ( error : unknown ) {
2931- producedError = error ;
2932- }
2933- expect ( ( producedError as Error ) . message ) . toContain ( 'NG0508' ) ;
2921+ const consoleSpy = spyOn ( console , 'warn' ) ;
2922+ resetIncrementalHydrationEnabledWarnedForTests ( ) ;
2923+
2924+ const doc = getDocument ( ) ;
2925+ await prepareEnvironmentAndHydrate ( doc , html , SimpleComponent , {
2926+ envProviders : [ ... providers , { provide : PLATFORM_ID , useValue : 'browser' } ] ,
2927+ // Empty list, `withIncrementalHydration()` is not included intentionally.
2928+ hydrationFeatures : ( ) => [ ] ,
2929+ } ) ;
2930+
2931+ expect ( consoleSpy ) . toHaveBeenCalledTimes ( 1 ) ;
2932+ expect ( consoleSpy ) . toHaveBeenCalledWith ( jasmine . stringMatching ( 'NG0508' ) ) ;
29342933 } ) ;
29352934 } ) ;
29362935} ) ;
0 commit comments