Skip to content

Ability to Execute Javascript between Resizes on Percy CLI Snapshot #513

@cancan101

Description

@cancan101

It would be great to be able to run JS (execute) between each width. Currently I am using the execute ability to scroll to the bottom of the page in order to trigger lazily loaded images. However since execute runs only once after the last width is set, the only images that are loaded are those requested by the last width. Instead it would be good to be able to either declaratively scroll to the bottom or more generally run JS between width changes.

This is the JS code that I am running:

function sleep(ms) {
   return new Promise(resolve => setTimeout(resolve, ms));
}
window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" });
await sleep(2000);
window.scrollTo(0,0);
await sleep(5000);

This comes up when using a srcset with any sort of lazy loading behavior.

The current flow is:

set initial width
go to page
iterate over widths, ending on the last one
wait for any specified timeout
wait for any specified selector
execute any javascript
wait for network

This issue comes up for example on any pages using next.js' next/image.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions