test(snapshot): speed up aria-label screenshot coverage
Optimize the real-page aria label screenshot integration test by reducing page load overhead (parallel page setup and lighter load wait), while keeping meaningful coverage on complex public pages. Use old.reddit.com and Hacker News for coverage, preserve label rendering and screenshot assertions, and bump playwriter version/changelog.
This commit is contained in:
@@ -1,5 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.0.68
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
- **Use a more realistic complex page in aria label screenshot test**: Replaced `example.com` with `old.reddit.com` in the optimized label rendering integration test to keep stronger real-world DOM coverage while preserving faster runtime.
|
||||||
|
|
||||||
|
## 0.0.67
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
- **Speed up aria label screenshot integration test**: Reduced the `should show aria ref labels on real pages and save screenshots` runtime by loading fewer external pages, removing `networkidle` waits, and parallelizing initial page loading.
|
||||||
|
|
||||||
## 0.0.66
|
## 0.0.66
|
||||||
|
|
||||||
### Internal
|
### Internal
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "playwriter",
|
"name": "playwriter",
|
||||||
"description": "",
|
"description": "",
|
||||||
"version": "0.0.66",
|
"version": "0.0.68",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -747,9 +747,8 @@ describe('Snapshot & Screenshot Tests', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const testPages = [
|
const testPages = [
|
||||||
|
{ name: 'old-reddit', url: 'https://old.reddit.com/' },
|
||||||
{ name: 'hacker-news', url: 'https://news.ycombinator.com/' },
|
{ name: 'hacker-news', url: 'https://news.ycombinator.com/' },
|
||||||
{ name: 'google', url: 'https://www.google.com/' },
|
|
||||||
{ name: 'github', url: 'https://github.com/' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const loadPageWithRetries = async ({ name, url }: { name: string; url: string }) => {
|
const loadPageWithRetries = async ({ name, url }: { name: string; url: string }) => {
|
||||||
@@ -761,8 +760,7 @@ describe('Snapshot & Screenshot Tests', () => {
|
|||||||
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
||||||
try {
|
try {
|
||||||
console.log(`[labels] opening ${name}: ${url} (attempt ${attempt}/${attempts})`)
|
console.log(`[labels] opening ${name}: ${url} (attempt ${attempt}/${attempts})`)
|
||||||
await page.goto(url, { waitUntil: 'domcontentloaded' })
|
await page.goto(url, { waitUntil: 'load' })
|
||||||
await page.waitForLoadState('networkidle', { timeout: 15000 })
|
|
||||||
console.log(`[labels] loaded ${name}: ${page.url()}`)
|
console.log(`[labels] loaded ${name}: ${page.url()}`)
|
||||||
return { name, url, page }
|
return { name, url, page }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -774,10 +772,9 @@ describe('Snapshot & Screenshot Tests', () => {
|
|||||||
throw new Error(`Failed to load ${name} after ${attempts} attempts`, { cause: lastError instanceof Error ? lastError : undefined })
|
throw new Error(`Failed to load ${name} after ${attempts} attempts`, { cause: lastError instanceof Error ? lastError : undefined })
|
||||||
}
|
}
|
||||||
|
|
||||||
const pages: Array<{ name: string; url: string; page: Page }> = []
|
const pages = await Promise.all(testPages.map((testPage) => {
|
||||||
for (const testPage of testPages) {
|
return loadPageWithRetries(testPage)
|
||||||
pages.push(await loadPageWithRetries(testPage))
|
}))
|
||||||
}
|
|
||||||
|
|
||||||
for (const { page } of pages) {
|
for (const { page } of pages) {
|
||||||
await page.bringToFront()
|
await page.bringToFront()
|
||||||
@@ -824,9 +821,7 @@ describe('Snapshot & Screenshot Tests', () => {
|
|||||||
60000
|
60000
|
||||||
)
|
)
|
||||||
console.log(`${name}: ${labelCount} labels shown`)
|
console.log(`${name}: ${labelCount} labels shown`)
|
||||||
if (name !== 'google') {
|
|
||||||
expect(labelCount).toBeGreaterThan(0)
|
expect(labelCount).toBeGreaterThan(0)
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`[labels] screenshot ${name}`)
|
console.log(`[labels] screenshot ${name}`)
|
||||||
const screenshot = await withTimeout(
|
const screenshot = await withTimeout(
|
||||||
|
|||||||
Reference in New Issue
Block a user