Skip to content

Commit 5a062ce

Browse files
test: stabilize test locally (#418)
Locally the test `with full page resulting in a large screenshot` would fail semi consistently. With what I think is just things not getting loaded fully, so scroll to the bottom to fix that.
1 parent cb5ca5a commit 5a062ce

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/tools/screenshot.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {describe, it} from 'node:test';
1111

1212
import {screenshot} from '../../src/tools/screenshot.js';
1313
import {screenshots} from '../snapshot.js';
14-
import {withBrowser} from '../utils.js';
14+
import {html, withBrowser} from '../utils.js';
1515

1616
describe('screenshot', () => {
1717
describe('browser_take_screenshot', () => {
@@ -77,9 +77,20 @@ describe('screenshot', () => {
7777
it('with full page resulting in a large screenshot', async () => {
7878
await withBrowser(async (response, context) => {
7979
const page = context.getSelectedPage();
80+
8081
await page.setContent(
81-
`<div style="color:blue;">test</div>`.repeat(7_000),
82+
html`${`<div style="color:blue;">test</div>`.repeat(6500)}
83+
<div
84+
id="red"
85+
style="color:blue;"
86+
>test</div
87+
> `,
8288
);
89+
await page.evaluate(() => {
90+
const el = document.querySelector('#red');
91+
return el?.scrollIntoViewIfNeeded();
92+
});
93+
8394
await screenshot.handler(
8495
{params: {format: 'png', fullPage: true}},
8596
response,

0 commit comments

Comments
 (0)