File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1+ import { readFile } from 'node:fs/promises' ;
12import type { Finding } from './types.d.js' ;
23import AxeBuilder from '@axe-core/playwright'
34import playwright from 'playwright' ;
45
56export async function findForUrl ( url : string , sessionStatePath ?: string ) : Promise < Finding [ ] > {
67 const browser = await playwright . chromium . launch ( { headless : true , executablePath : process . env . CI ? '/usr/bin/google-chrome' : undefined } ) ;
7- const context = await browser . newContext ( { storageState : sessionStatePath } ) ;
8+ let sessionState ;
9+ if ( sessionStatePath ) {
10+ try {
11+ sessionState = JSON . parse ( await readFile ( sessionStatePath , 'utf8' ) ) ;
12+ } catch ( error ) {
13+ console . error ( `Error reading or parsing session state file at path: ${ sessionStatePath } ` , error ) ;
14+ }
15+ }
16+ const context = await browser . newContext ( { storageState : sessionState } ) ;
817 const page = await context . newPage ( ) ;
918 await page . goto ( url ) ;
1019
You can’t perform that action at this time.
0 commit comments