@@ -105,20 +105,35 @@ describe('watch mode - watch flags', { concurrency: !process.env.TEST_PARALLEL,
105105 const watchPath = path . join ( projectDir , 'template.html' ) ;
106106 writeFileSync ( watchPath , '' ) ;
107107
108- async function assertExecArgv ( args , expected ) {
108+ async function assertExecArgv ( args , expectedPrefixes ) {
109109 const { stdout, stderr } = await runNode ( {
110110 args, options : { cwd : projectDir }
111111 } ) ;
112112
113113 assert . strictEqual ( stderr , '' ) ;
114114
115115 const execArgvLine = stdout [ 0 ] ;
116- assert . deepStrictEqual ( JSON . parse ( execArgvLine ) , expected ) ;
116+ const execArgv = JSON . parse ( execArgvLine ) ;
117+ assert . ok ( Array . isArray ( execArgv ) ) ;
118+ const matched = expectedPrefixes . some ( ( expectedPrefix ) => {
119+ if ( execArgv . length < expectedPrefix . length ) {
120+ return false ;
121+ }
122+ return execArgv . slice ( 0 , expectedPrefix . length )
123+ . every ( ( value , idx ) => value === expectedPrefix [ idx ] ) ;
124+ } ) ;
125+ assert . ok ( matched ,
126+ `execArgv (${ execArgv } ) does not start with any expected prefix (${ expectedPrefixes . map ( ( p ) => `[${ p } ]` ) . join ( ', ' ) } )` ) ;
117127 assert . match ( stdout . at ( - 1 ) , / ^ C o m p l e t e d r u n n i n g / ) ;
118128 }
119129
120- await assertExecArgv ( [ '--watch' , file ] , [ '--watch' ] ) ;
121- await assertExecArgv ( [ '--watch-path=template.html' , file ] , [ '--watch-path=template.html' ] ) ;
122- await assertExecArgv ( [ '--watch-path' , 'template.html' , file ] , [ '--watch-path' , 'template.html' ] ) ;
130+ await assertExecArgv ( [ '--watch' , file ] , [ [ '--watch' ] ] ) ;
131+ await assertExecArgv ( [ '--watch-path=template.html' , file ] , [ [ '--watch-path=template.html' ] ] ) ;
132+ await assertExecArgv (
133+ [ '--watch-path' , 'template.html' , file ] ,
134+ [
135+ [ '--watch-path' , 'template.html' ] ,
136+ [ '--watch-path=template.html' ] ,
137+ ] ) ;
123138 } ) ;
124139} ) ;
0 commit comments