In my test I want to wait for a request but if a particular timeout expires, I want to ignore the request response. But using the waitForResponse function, if the request never responds before the timeout the page is closed and the test ends.
So, how to optionally look for the response to test degraded mode in Playwright ?
You can catch the timeout error:
That said, it's an antipattern to have conditions in tests. Tests should be deterministic to the extent you can make them. If you have two different application states to test, prefer writing separate tests, taking care to set up the necessary conditions to reproduce each application state.
Cypress has a thorough article on conditional testing, and the main points hold true in Playwright as well.