Skip to content

Commit 45d0931

Browse files
committed
feat: Add logs for debugging
1 parent c945c7a commit 45d0931

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/actions/find/src/findForUrl.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
import { readFile } from 'node:fs/promises';
12
import type { Finding } from './types.d.js';
23
import AxeBuilder from '@axe-core/playwright'
34
import playwright from 'playwright';
45

56
export 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

0 commit comments

Comments
 (0)