[Feature] Extend expect() timeout after it started waiting
See original GitHub issueI’d like way to extend the expect timeout similarly to how I can extend the test timeout:
testInfo.setTimeout(testInfo.timeout + 30000)
Use case
I’m testing a rate limited backend and sometimes it gets overloaded. In that case my tests need to wait 10-20 seconds, sometimes up to 60 seconds before a backend requests can successfully be retried. I don’t want to extend all expect timeouts to 60+ seconds as that would make failure detection very slow. But I can detect the backend rate limitation kicking in and in that case I already increase the test timeout. I’d like to do the same for the expect timeout.
This is the current function I use to extend the currently running test timeout
function tryToExtendPlaywrightTestTimeout(extendByMs: number) {
test.info().setTimeout(testInfo.timeout + extendByMs)
// would be nice to have a way to extend the timeout of the currently running expect(...) -- if one is running
}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
settimeout and wait if timeout already set - Stack Overflow
How to create queue for settimeout function.
Read more >Timeouts - WebdriverIO
A session has an associated session implicit wait timeout. This specifies the time to wait for the implicit element location strategy when locating...
Read more >Async Methods - Testing Library
These can be useful to wait for an element to appear or disappear in response to an event, user action, timeout, or Promise....
Read more >mocha.timeout JavaScript and Node.js code examples - Tabnine
after ( async function () { this.timeout( 30000 ); await driver. ... wait for after start app.stop(false); setTimeout(function () { // wait for...
Read more >How to Timeout a fetch() Request - Dmitri Pavlutin
const id = setTimeout(() => controller.abort(), timeout) starts a timing function. After timeout time, if the timining function wasn't ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It would work fine for success / Failure detection. The only drawback is the lack of the the more accurate expect failure error messages. The test timeout error messages are less detailed, harder to debug.
Along these lines I think setting the expect timeout sufficiently high (30-60 seconds) will avoid most of the congestion issues and still give me a more helpful error message. Thanks for the inspiration @aslushnikov !
@cassus I’d recommend you to disable expect timeout via
testProject.expect.timeout
and only change the test timeout viatestInfo.setTiemout
.Would this workaround work?