question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Extend expect() timeout after it started waiting

See original GitHub issue

I’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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cassuscommented, Jun 1, 2022

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 !

0reactions
aslushnikovcommented, Jun 1, 2022

@cassus I’d recommend you to disable expect timeout via testProject.expect.timeout and only change the test timeout via testInfo.setTiemout.

Would this workaround work?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found