Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 87e99fe

Browse files
committed
Optimize TestPageScreenshotFullpage
This is the slowest test we have (see #612). This optimization speeds up the test 35% on my machine. Before: 671259438 ns/op 43410268 B/op 8771 allocs/op After : 363529042 ns/op 5970741 B/op 8533 allocs/op
1 parent 47bdfb0 commit 87e99fe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/page_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ func TestPageScreenshotFullpage(t *testing.T) {
399399
400400
const div = document.createElement('div');
401401
div.style.width = '1280px';
402-
div.style.height = '8000px';
402+
div.style.height = '800px';
403403
div.style.background = 'linear-gradient(red, blue)';
404404
405405
document.body.appendChild(div);
@@ -415,12 +415,12 @@ func TestPageScreenshotFullpage(t *testing.T) {
415415
assert.Nil(t, err)
416416

417417
assert.Equal(t, 1280, img.Bounds().Max.X, "screenshot width is not 1280px as expected, but %dpx", img.Bounds().Max.X)
418-
assert.Equal(t, 8000, img.Bounds().Max.Y, "screenshot height is not 8000px as expected, but %dpx", img.Bounds().Max.Y)
418+
assert.Equal(t, 800, img.Bounds().Max.Y, "screenshot height is not 800px as expected, but %dpx", img.Bounds().Max.Y)
419419

420420
r, _, b, _ := img.At(0, 0).RGBA()
421421
assert.Greater(t, r, uint32(128))
422422
assert.Less(t, b, uint32(128))
423-
r, _, b, _ = img.At(0, 7999).RGBA()
423+
r, _, b, _ = img.At(0, 799).RGBA()
424424
assert.Less(t, r, uint32(128))
425425
assert.Greater(t, b, uint32(128))
426426
}

0 commit comments

Comments
 (0)