percy / cli

The Percy CLI is used to interact with, and upload snapshots to, percy.io via the command line.
https://docs.percy.io/docs/cli-overview
70 stars 43 forks source link

Allow per-snapshot configuration of discovery.networkIdleTimeout #1360

Open Conduitry opened 1 year ago

Conduitry commented 1 year ago

If I have just a couple of snapshots that are flaky because the default discovery network idle timeout is too low, it would be convenient to be able to specify an increased value specifically for those snapshots - without increasing it unnecessarily for all snapshots, slowing down the build.

As far as I can tell, this is not supported. Is there another way to achieve a similar result?

itsjwala commented 1 year ago

Currently, there isn't a way if you're using percy exec -- based SDK

though if you're using percy snapshot ... there is a workaround where you can pass in execute function OR waitForTimeout which would be executed before taking snapshot.

serve: './'

snapshots:
- name: sample snapshot
  url: /sample.html
  widths: [1280]
  waitForTimeout: 2000
  execute: |
    async () => {
        function sleep(time) {
          return new Promise((resolve) => setTimeout(resolve, time));
        }
        await sleep(2000);
    }
itsjwala commented 1 year ago

we'd be happy to receive a PR, it will require change here - ref { and associated readme and tests)

we'll need to add networkIdleTimeout entry there, post which we can pass like below to make it work

with percy snapshot ...

serve: './'

snapshots:
- name: sample snapshot
  url: /sample.html
  widths: [1280]
  discovery:
    networkIdleTimeout: 500

or if using percy exec ...

await percySnapshot(page, 'sample snapshot', {
   discovery: {
    networkIdleTimeout: 500
   }
});