6
6
* found in the LICENSE file at https://angular.dev/license
7
7
*/
8
8
9
- import { TimeoutError , concatMap , count , take , timeout } from 'rxjs' ;
9
+ import { TimeoutError } from 'rxjs' ;
10
10
import { executeDevServer } from '../../index' ;
11
11
import { 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' ;
13
13
14
14
describeServeBuilder ( executeDevServer , DEV_SERVER_BUILDER_INFO , ( harness , setupTarget ) => {
15
15
describe ( 'Option: "watch"' , ( ) => {
@@ -24,27 +24,21 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
24
24
} ) ;
25
25
26
26
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
31
30
expect ( result ?. success ) . toBe ( true ) ;
32
31
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
+ ] )
48
42
. catch ( ( error ) => {
49
43
// Timeout is expected if watching is disabled
50
44
if ( error instanceof TimeoutError ) {
@@ -60,30 +54,22 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
60
54
watch : undefined ,
61
55
} ) ;
62
56
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 ) ;
85
61
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
+ ] ) ;
87
73
} ) ;
88
74
89
75
it ( 'watches for file changes when true' , async ( ) => {
@@ -92,30 +78,22 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
92
78
watch : true ,
93
79
} ) ;
94
80
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 ) ;
117
85
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
+ ] ) ;
119
97
} ) ;
120
98
} ) ;
121
99
} ) ;
0 commit comments