@@ -3,11 +3,12 @@ import { Config, Scenario, ViewportNext } from 'backstopjs';
3
3
import { createScenario } from './scenarios.js' ;
4
4
import path from 'path' ;
5
5
import { getFlagArg , getStringArg , parseDataFromFile , getLibraryPath } from './helpers.js' ;
6
- import { TestSuiteModel , ScenarioModel } from './types.js' ;
6
+ import { TestSuiteModel , ScenarioModel , PersistAction } from './types.js' ;
7
7
import chalk from 'chalk' ;
8
8
import { exit } from 'process' ;
9
9
import YAML from 'js-yaml' ;
10
10
import { getTestUrl } from './replacements.js' ;
11
+ import { getStatePath } from './state.js' ;
11
12
12
13
const libraryPath = getLibraryPath ( ) ;
13
14
const engine : 'puppeteer' | 'playwright' = 'playwright' ;
@@ -126,11 +127,6 @@ function getScenarios(args: string[], testSuite: string, isRef: boolean, globalR
126
127
total : data . scenarios . length ,
127
128
delay : s . delay ?? 1000 ,
128
129
state : s . state ?? data . state ,
129
- restore : ! data . restore
130
- ? s . restore
131
- : ! s . restore
132
- ? data . restore
133
- : [ ...( typeof data . restore === 'string' ? [ data . restore ] : data . restore ) , ...( typeof s . restore === 'string' ? [ s . restore ] : s . restore ) ] ,
134
130
hideSelectors : s . hideSelectors ?? data . hideSelectors ,
135
131
removeSelectors : s . removeSelectors ?? data . removeSelectors ,
136
132
useCssOverride : s . useCssOverride ?? data . useCssOverride ,
@@ -154,6 +150,14 @@ function getScenarios(args: string[], testSuite: string, isRef: boolean, globalR
154
150
opts . restore = opts . restore . filter ( ( value , index , self ) => self . indexOf ( value ) === index ) ;
155
151
}
156
152
153
+ if ( opts . actions && Array . isArray ( opts . actions ) ) {
154
+ let persistActions = opts . actions . filter ( ( a ) => ( a as PersistAction ) . persist ) as PersistAction [ ] ;
155
+ for ( const persistAction of persistActions ) {
156
+ persistAction . path = getStatePath ( persistAction . persist as string ) ;
157
+ console . log ( 'Persist action: ' , persistAction ) ;
158
+ }
159
+ }
160
+
157
161
const scenario = createScenario ( opts ) ;
158
162
scenarios . push ( scenario ) ;
159
163
} ) ;
@@ -193,6 +197,7 @@ export function getConfig(args: string[]): Config {
193
197
browser : data ?. browser ?? 'chromium' ,
194
198
ignoreHTTPSErrors : data && typeof data ?. ignoreSslErrors === 'boolean' ? data . ignoreSslErrors : true ,
195
199
headless : data ?. debug ? undefined : 'new' ,
200
+ storageState : data ?. state ? getStatePath ( data . state ) : undefined ,
196
201
} ,
197
202
asyncCaptureLimit : data ?. asyncCaptureLimit ?? 5 ,
198
203
asyncCompareLimit : data ?. asyncCompareLimit ?? 50 ,
0 commit comments