@@ -54,8 +54,7 @@ program
5454 "-b, --browser <browsers...>" ,
5555 "Run tests in a specific browser. Pass multiple browsers by repeating the option. " +
5656 "If using BrowserStack, specify browsers using --browserstack. " +
57- "Choices: " + browsers . join ( ", " ) +
58- ". Defaults to Chrome."
57+ "Choices: " + browsers . join ( ", " ) + ". Defaults to Chrome."
5958 )
6059 . option (
6160 "-m, --middleware <middlewares...>" ,
@@ -88,10 +87,7 @@ program
8887 "when the normal retries are exhausted." ,
8988 parseInt
9089 )
91- . option (
92- "-v, --verbose" ,
93- "Log additional information."
94- )
90+ . option ( "-v, --verbose" , "Log additional information." )
9591 . option (
9692 "--browserstack <configs...>" ,
9793 "Run tests in BrowserStack. Requires BROWSERSTACK_USERNAME and " +
@@ -112,14 +108,8 @@ program
112108 testUrl : config . testUrls ,
113109 ...argv
114110 } ;
115- options . flag = [
116- ...parseFlags ( config . flags ) ,
117- ...( options . flag ?? [ ] )
118- ] ;
119- options . run = [
120- ...parseRuns ( config . runs ) ,
121- ...( options . run ?? [ ] )
122- ] ;
111+ options . flag = [ ...parseFlags ( config . flags ) , ...( options . flag ?? [ ] ) ] ;
112+ options . run = [ ...parseRuns ( config . runs ) , ...( options . run ?? [ ] ) ] ;
123113 options . middleware = await parseMiddleware ( options ) ;
124114
125115 return runTests ( options ) ;
@@ -139,10 +129,7 @@ program
139129 "Base URL for the test server. " +
140130 "Expected to always start and end with a slash (/). Defaults to \"/test/\"."
141131 )
142- . option (
143- "-p, --port <number>" ,
144- "Port to listen on. Defaults to 3000."
145- )
132+ . option ( "-p, --port <number>" , "Port to listen on. Defaults to 3000." )
146133 . option (
147134 "-q, --quiet" ,
148135 "Whether to log requests to the console. Default: false."
@@ -172,7 +159,9 @@ program
172159 const app = await createTestServer ( options ) ;
173160
174161 return app . listen ( { port : options . port , host : "0.0.0.0" } , function ( ) {
175- console . log ( `Open tests at http://localhost:${ options . port } ${ options . baseUrl } ` ) ;
162+ console . log (
163+ `Open tests at http://localhost:${ options . port } ${ options . baseUrl } `
164+ ) ;
176165 } ) ;
177166 } ) ;
178167
@@ -189,7 +178,8 @@ program
189178 "Use a colon to indicate a device.\n" +
190179 "Examples: \"chrome__windows_10\", \"safari_latest\", " +
191180 "\"Mobile Safari\", \"Android Browser_:Google Pixel 8 Pro\".\n" +
192- "Use quotes if spaces are necessary."
181+ "Use quotes if spaces are necessary. Requires BROWSERSTACK_USERNAME and " +
182+ "BROWSERSTACK_ACCESS_KEY environment variables."
193183 )
194184 . action ( ( filter ) => {
195185 console . log ( "Listing browsers with filter:" , filter ) ;
@@ -202,7 +192,9 @@ program
202192 . description (
203193 "WARNING: This will stop all BrowserStack workers that may exist and exit," +
204194 "including any workers running from other projects.\n" +
205- "This can be used as a failsafe when there are too many stray workers."
195+ "This can be used as a failsafe when there are too many stray workers." +
196+ "Requires BROWSERSTACK_USERNAME and " +
197+ "BROWSERSTACK_ACCESS_KEY environment variables."
206198 )
207199 . action ( ( ) => {
208200 console . log ( "Stopping workers..." ) ;
@@ -212,7 +204,11 @@ program
212204// Define the browserstack-plan command
213205program
214206 . command ( "browserstack-plan" )
215- . description ( "Show BrowserStack plan information and exit." )
207+ . description (
208+ "Show BrowserStack plan information and exit. " +
209+ "Requires BROWSERSTACK_USERNAME and " +
210+ "BROWSERSTACK_ACCESS_KEY environment variables."
211+ )
216212 . action ( async ( ) => {
217213 console . log ( await getPlan ( ) ) ;
218214 } ) ;
@@ -252,16 +248,14 @@ function parseRuns( runs ) {
252248
253249async function parseMiddleware ( options ) {
254250 const middleware = await Promise . all (
255- ( options . middleware ?? [ ] ) . map (
256- async ( mw ) => {
257- const filepath = pathToFileURL ( resolve ( process . cwd ( ) , mw ) ) . toString ( ) ;
258- if ( options . verbose ) {
259- console . log ( `Loading middleware from ${ filepath } ...` ) ;
260- }
261- const module = await import ( filepath ) ;
262- return module . default ;
251+ ( options . middleware ?? [ ] ) . map ( async ( mw ) => {
252+ const filepath = pathToFileURL ( resolve ( process . cwd ( ) , mw ) ) . toString ( ) ;
253+ if ( options . verbose ) {
254+ console . log ( `Loading middleware from ${ filepath } ...` ) ;
263255 }
264- )
256+ const module = await import ( filepath ) ;
257+ return module . default ;
258+ } )
265259 ) ;
266260 return middleware ;
267261}
0 commit comments