pptr-testing-library
pptr-testing-library copied to clipboard
Support `configure` (global default timeout for findBy* queries)
Before I started to use this library, I used the puppeteer method waitForSelector
in order to find elements on a page. By default, the timeout was set to 30 seconds.
Now, I wish to use this library and replace all the waitForSelector
occurrences with findBy*
queries, which similarly wait until the element appears or if there's a timeout. Unfortunately, the default timeout of those queries is only 1 second.
There is, however, an option to change the timeout to some other value, for example by doing findByText('some text', {}, {timeout: 30_000})
, but I'd like to have a cleaner solution where I don't have to state the timeout over and over again.
Furthermore, I read that it is possible to globally configure the testing library, and pass an asyncUtilTimeout
configuration with the default timeout, but this configuration didn't seem to work as expected with this library.
After looking into the code, I think the issue might be related to the exported configure
method, which supports only a testIdAttribute
configuration.
Is there some other option to set the timeout globally for all the queries? And if not, should this library support this configuration the same way other libraries within the testing-library family support it?
Thanks
Thanks for filing @IdanGoor! Yeah configure
is going to be tricky for this library because the library is injected into the page on every evaluation (so any state from prior calls is lost).
PR welcome to enable configure support for any potential contributors! :)
Thanks for the response @patrickhulce :) I opened a PR regarding this enhancement, and would love to hear your opinion about it