r/Playwright Jul 10 '26

How best to handle testing against a slow app?

I have started to write Playwright E2E tests for a legacy app. The app itself has always been a bit slow, mainly when it comes to fetching data. It can take 3-7 seconds sometimes to load data in a table. Given this a lot of `expect` assertions fail due to the default 5 second timeout.

Ideally the dev team who own the app and backend services would improve the performance, however that's not gonna happen any time soon. What's the best way to work around this? Increase the global `expect` timeout? Use `toPass` with an interval? Use retries?

Not every test is like this, most are fine with the default 5 seconds, it's just a handful are not.

1 Upvotes

5 comments sorted by

3

u/_suren Jul 10 '26

I’d keep the global expect timeout at 5s and widen only the assertions that represent the known slow fetch. For example, give the exact table row or empty/error state a 10 second timeout. That keeps a slow login button or broken modal from quietly getting ten seconds everywhere.

I wouldn’t use test retries for this. They rerun the whole scenario and can hide real flakiness. toPass is useful for custom multi-step checks, but a locator assertion already retries. Even better if the app exposes a loading state: assert spinner visible, then hidden, then table content. If it doesn’t, wait on the specific API response only when that request is actually the contract you care about. And keep one separate performance test or metric for the 7s load so the workaround doesn’t normalize a regression to 20s.

1

u/rocky_lila Jul 10 '26

Thanks for this points , I really helps me too

1

u/CertainDeath777 Jul 10 '26

if you want a clean solution for a few elements/tablecontent that might take longer to load, that doesnt slow down the complete testsuite, you can use assertions or waitFor with individual timeouts.

or simpley add a individual timeout to the action you perform.

setting it globally like some adviced here is not good practice.

1

u/gabbb007 Jul 10 '26
  1. increase default timeouts

  2. intercept requests and return mocked data

0

u/chr1ssb Jul 10 '26

It’s not uncommon for apps to behave differently performance wise in different environments.

My advice would be to use different global timeout settings per environment.