Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configure (global default timeout for findBy* queries) #71

Open
IdanGoor opened this issue Apr 23, 2022 · 2 comments
Open

Support configure (global default timeout for findBy* queries) #71

IdanGoor opened this issue Apr 23, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@IdanGoor
Copy link

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

@patrickhulce
Copy link
Collaborator

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! :)

@patrickhulce patrickhulce added the enhancement New feature or request label Apr 24, 2022
@patrickhulce patrickhulce changed the title Setting a global default timeout for findBy* queries Support configure (global default timeout for findBy* queries) Apr 24, 2022
@IdanGoor
Copy link
Author

Thanks for the response @patrickhulce :)
I opened a PR regarding this enhancement, and would love to hear your opinion about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants