@@ -54,8 +54,7 @@ program
54
54
"-b, --browser <browsers...>" ,
55
55
"Run tests in a specific browser. Pass multiple browsers by repeating the option. " +
56
56
"If using BrowserStack, specify browsers using --browserstack. " +
57
- "Choices: " + browsers . join ( ", " ) +
58
- ". Defaults to Chrome."
57
+ "Choices: " + browsers . join ( ", " ) + ". Defaults to Chrome."
59
58
)
60
59
. option (
61
60
"-m, --middleware <middlewares...>" ,
@@ -88,10 +87,7 @@ program
88
87
"when the normal retries are exhausted." ,
89
88
parseInt
90
89
)
91
- . option (
92
- "-v, --verbose" ,
93
- "Log additional information."
94
- )
90
+ . option ( "-v, --verbose" , "Log additional information." )
95
91
. option (
96
92
"--browserstack <configs...>" ,
97
93
"Run tests in BrowserStack. Requires BROWSERSTACK_USERNAME and " +
@@ -112,14 +108,8 @@ program
112
108
testUrl : config . testUrls ,
113
109
...argv
114
110
} ;
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 ?? [ ] ) ] ;
123
113
options . middleware = await parseMiddleware ( options ) ;
124
114
125
115
return runTests ( options ) ;
@@ -139,10 +129,7 @@ program
139
129
"Base URL for the test server. " +
140
130
"Expected to always start and end with a slash (/). Defaults to \"/test/\"."
141
131
)
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." )
146
133
. option (
147
134
"-q, --quiet" ,
148
135
"Whether to log requests to the console. Default: false."
@@ -172,7 +159,9 @@ program
172
159
const app = await createTestServer ( options ) ;
173
160
174
161
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
+ ) ;
176
165
} ) ;
177
166
} ) ;
178
167
@@ -189,7 +178,8 @@ program
189
178
"Use a colon to indicate a device.\n" +
190
179
"Examples: \"chrome__windows_10\", \"safari_latest\", " +
191
180
"\"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."
193
183
)
194
184
. action ( ( filter ) => {
195
185
console . log ( "Listing browsers with filter:" , filter ) ;
@@ -202,7 +192,9 @@ program
202
192
. description (
203
193
"WARNING: This will stop all BrowserStack workers that may exist and exit," +
204
194
"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."
206
198
)
207
199
. action ( ( ) => {
208
200
console . log ( "Stopping workers..." ) ;
@@ -212,7 +204,11 @@ program
212
204
// Define the browserstack-plan command
213
205
program
214
206
. 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
+ )
216
212
. action ( async ( ) => {
217
213
console . log ( await getPlan ( ) ) ;
218
214
} ) ;
@@ -252,16 +248,14 @@ function parseRuns( runs ) {
252
248
253
249
async function parseMiddleware ( options ) {
254
250
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 } ...` ) ;
263
255
}
264
- )
256
+ const module = await import ( filepath ) ;
257
+ return module . default ;
258
+ } )
265
259
) ;
266
260
return middleware ;
267
261
}
0 commit comments