@@ -225,6 +225,45 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise<Record
225225 return false ;
226226 }
227227
228+ if ( options . web && Object . keys ( options . web ) . length ) {
229+ processedOptions . web = { } ;
230+
231+ // Check and process viewports in web
232+ if ( options . web . viewports && Array . isArray ( options . web . viewports ) && options . web . viewports . length > 0 ) {
233+ processedOptions . web . viewports = options . web . viewports . filter ( viewport =>
234+ Array . isArray ( viewport ) && viewport . length > 0
235+ ) ;
236+ }
237+
238+ // Check and process browsers in web
239+ if ( options . web . browsers && Array . isArray ( options . web . browsers ) && options . web . browsers . length > 0 ) {
240+ processedOptions . web . browsers = options . web . browsers ;
241+ }
242+ }
243+
244+ if ( options . mobile && Object . keys ( options . mobile ) . length ) {
245+ processedOptions . mobile = { } ;
246+
247+ // Check and process devices in mobile
248+ if ( options . mobile . devices && Array . isArray ( options . mobile . devices ) && options . mobile . devices . length > 0 ) {
249+ processedOptions . mobile . devices = options . mobile . devices ;
250+ }
251+
252+ // Check if 'fullPage' is provided and is a boolean, otherwise set default to true
253+ if ( 'fullPage' in options . mobile && typeof options . mobile . fullPage === 'boolean' ) {
254+ processedOptions . mobile . fullPage = options . mobile . fullPage ;
255+ } else {
256+ processedOptions . mobile . fullPage = true ; // Default value for fullPage
257+ }
258+
259+ // Check if 'orientation' is provided and is valid, otherwise set default to 'portrait'
260+ if ( 'orientation' in options . mobile && ( options . mobile . orientation === 'portrait' || options . mobile . orientation === 'landscape' ) ) {
261+ processedOptions . mobile . orientation = options . mobile . orientation ;
262+ } else {
263+ processedOptions . mobile . orientation = 'portrait' ; // Default value for orientation
264+ }
265+ }
266+
228267 if ( options . element && Object . keys ( options . element ) . length ) {
229268 if ( options . element . id ) processedOptions . element = '#' + options . element . id ;
230269 else if ( options . element . class ) processedOptions . element = '.' + options . element . class ;
@@ -334,6 +373,7 @@ async function processSnapshot(snapshot: Snapshot, ctx: Context): Promise<Record
334373 } ) ;
335374 }
336375 }
376+ ctx . log . debug ( `Processed options: ${ JSON . stringify ( processedOptions ) } ` ) ;
337377 }
338378
339379 return {
0 commit comments