-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Question] Wait for response.ok() #2821
Comments
(thought first, this issue was open in a jest-playwright repo, then saw its the Playwright repo itself) From the first thoughts, it seems that this might be the right feature for you: https://github.com/playwright-community/jest-process-manager Also supported for jest-playwright: https://github.com/playwright-community/jest-playwright#configuration |
Thanks @mxschmitt. In my case I'm working on a new framework. Testing the CLI and dev-server is part of the tests, rather than being the environment for the tests. I hope that makes sense. Is it possible to check if an address returns status 2xx within a given timeframe with Playwright? |
Yes, it supports http/https based applications and will start the Jest tests once a 2xx status test will be returned. Useful for dev servers like create-react-app has. |
How would I do this with Playwright? |
See this repo for jest-playwright examples including React: https://github.com/playwright-community/playwright-jest-examples |
I think there might be a misunderstanding. I'm looking for a Playwright native function like |
Ah gotcha. If you want to use this feature directly, you can use the wait-on package. Is this enough for your needs? From my understanding integrating wait-on in your wrapper would solve this issue. |
Thanks, didn't know about the wait-on package. The wrapper is already working, but had hoped for a cleaner solution. I'll have a look at wait-on and see if it's worth replacing the wrapper. |
@jakobrosenberg In ideal world, server would notify clients when it's up and running - but sometimes there's no way to get perfect behavior.. The workaround that you use is not that bad for what it does. Alternatively, I'd consider firing HTTP requests from node.js itself since it's way more lightweight than browser page navigation. |
I'm not sure if this already exist. I tried
waitForResponse
, but didn't get the desired result.For my tests I need to run a dev-server, which takes up to 15 seconds to start. It would be great if there was a native way to poll a server for
response.ok()
to be truthy within a set interval.As a workaround, I'm using the following code
The text was updated successfully, but these errors were encountered: