66 * found in the LICENSE file at https://angular.dev/license
77 */
88
9- import { TimeoutError , concatMap , count , take , timeout } from 'rxjs' ;
9+ import { TimeoutError } from 'rxjs' ;
1010import { executeDevServer } from '../../index' ;
1111import { describeServeBuilder } from '../jasmine-helpers' ;
12- import { BASE_OPTIONS , BUILD_TIMEOUT , DEV_SERVER_BUILDER_INFO } from '../setup' ;
12+ import { BASE_OPTIONS , DEV_SERVER_BUILDER_INFO } from '../setup' ;
1313
1414describeServeBuilder ( executeDevServer , DEV_SERVER_BUILDER_INFO , ( harness , setupTarget ) => {
1515 describe ( 'Option: "watch"' , ( ) => {
@@ -24,27 +24,21 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
2424 } ) ;
2525
2626 await harness
27- . execute ( )
28- . pipe (
29- timeout ( BUILD_TIMEOUT ) ,
30- concatMap ( async ( { result } , index ) => {
27+ . executeWithCases ( [
28+ async ( { result } ) => {
29+ // Initial build should succeed
3130 expect ( result ?. success ) . toBe ( true ) ;
3231
33- switch ( index ) {
34- case 0 :
35- await harness . modifyFile (
36- 'src/main.ts' ,
37- ( content ) => content + 'console.log("abcd1234");' ,
38- ) ;
39- break ;
40- case 1 :
41- fail ( 'Expected files to not be watched.' ) ;
42- break ;
43- }
44- } ) ,
45- take ( 2 ) ,
46- )
47- . toPromise ( )
32+ // Modify a file to attempt to trigger file watcher
33+ await harness . modifyFile (
34+ 'src/main.ts' ,
35+ ( content ) => content + 'console.log("abcd1234");' ,
36+ ) ;
37+ } ,
38+ ( ) => {
39+ fail ( 'Expected files to not be watched.' ) ;
40+ } ,
41+ ] )
4842 . catch ( ( error ) => {
4943 // Timeout is expected if watching is disabled
5044 if ( error instanceof TimeoutError ) {
@@ -60,30 +54,22 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
6054 watch : undefined ,
6155 } ) ;
6256
63- const buildCount = await harness
64- . execute ( )
65- . pipe (
66- timeout ( BUILD_TIMEOUT ) ,
67- concatMap ( async ( { result } , index ) => {
68- expect ( result ?. success ) . toBe ( true ) ;
69-
70- switch ( index ) {
71- case 0 :
72- await harness . modifyFile (
73- 'src/main.ts' ,
74- ( content ) => content + 'console.log("abcd1234");' ,
75- ) ;
76- break ;
77- case 1 :
78- break ;
79- }
80- } ) ,
81- take ( 2 ) ,
82- count ( ) ,
83- )
84- . toPromise ( ) ;
57+ await harness . executeWithCases ( [
58+ async ( { result } ) => {
59+ // Initial build should succeed
60+ expect ( result ?. success ) . toBe ( true ) ;
8561
86- expect ( buildCount ) . toBe ( 2 ) ;
62+ // Modify a file to trigger file watcher
63+ await harness . modifyFile (
64+ 'src/main.ts' ,
65+ ( content ) => content + 'console.log("abcd1234");' ,
66+ ) ;
67+ } ,
68+ async ( { result } ) => {
69+ // Modifying a file should trigger a successful rebuild
70+ expect ( result ?. success ) . toBe ( true ) ;
71+ } ,
72+ ] ) ;
8773 } ) ;
8874
8975 it ( 'watches for file changes when true' , async ( ) => {
@@ -92,30 +78,22 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
9278 watch : true ,
9379 } ) ;
9480
95- const buildCount = await harness
96- . execute ( )
97- . pipe (
98- timeout ( BUILD_TIMEOUT ) ,
99- concatMap ( async ( { result } , index ) => {
100- expect ( result ?. success ) . toBe ( true ) ;
101-
102- switch ( index ) {
103- case 0 :
104- await harness . modifyFile (
105- 'src/main.ts' ,
106- ( content ) => content + 'console.log("abcd1234");' ,
107- ) ;
108- break ;
109- case 1 :
110- break ;
111- }
112- } ) ,
113- take ( 2 ) ,
114- count ( ) ,
115- )
116- . toPromise ( ) ;
81+ await harness . executeWithCases ( [
82+ async ( { result } ) => {
83+ // Initial build should succeed
84+ expect ( result ?. success ) . toBe ( true ) ;
11785
118- expect ( buildCount ) . toBe ( 2 ) ;
86+ // Modify a file to trigger file watcher
87+ await harness . modifyFile (
88+ 'src/main.ts' ,
89+ ( content ) => content + 'console.log("abcd1234");' ,
90+ ) ;
91+ } ,
92+ async ( { result } ) => {
93+ // Modifying a file should trigger a successful rebuild
94+ expect ( result ?. success ) . toBe ( true ) ;
95+ } ,
96+ ] ) ;
11997 } ) ;
12098 } ) ;
12199} ) ;
0 commit comments