Skip to content

Commit

Permalink
Better data on playwright failure
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairjcbrown committed Nov 3, 2024
1 parent 5b27306 commit 94c4020
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ jobs:
- run: npm run generate electriccinema.co.uk-portobello
- run: npm run generate electriccinema.co.uk-white-city

- name: Save any test failure artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-failures
path: ./playwright-failures
if-no-files-found: ignore
retention-days: 7

# Run post-data scripts
- run: npm run output:highlight-hydration-misses-for-review

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# output files
output/*
cache/*
playwright-failures/*

# Logs
logs
Expand Down
26 changes: 19 additions & 7 deletions common/bfi.org.uk/retrieve.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ async function getPageWithPlaywright(url, cacheKey, callback) {
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(url);
const result = await callback(page);
await browser.close();
return result;
try {
await page.goto(url);
const result = await callback(page);
await browser.close();
return result;
} catch (error) {
await page.screenshot({
path: `./playwright-failures/error--${cacheKey}.png`,
});
throw error;
}
});
}

Expand Down Expand Up @@ -49,9 +56,14 @@ async function processSearchResultPage(
await page.waitForLoadState("networkidle");
// Make sure there's information showing. Not all pages have film info
// (that we care about), so check for the rich text or media areas too
await page
.locator(".Film-info__information,.Rich-text,.Media")
.waitFor({ strict: false });
try {
await page
.locator(".Film-info__information,.Rich-text,.Media")
.waitFor({ strict: false });
} catch (error) {
console.error(`Page data not available at ${domain}${showUrl}`);
throw error;
}

return await page.content();
},
Expand Down

0 comments on commit 94c4020

Please sign in to comment.