cli icon indicating copy to clipboard operation
cli copied to clipboard

Allow per-snapshot configuration of discovery.networkIdleTimeout

Open Conduitry opened this issue 1 year ago • 2 comments

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?

Conduitry avatar Aug 31 '23 16:08 Conduitry

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 avatar Sep 01 '23 15:09 itsjwala

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
   }
});

itsjwala avatar Sep 01 '23 16:09 itsjwala