-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Playwright e2e tests are configured to start wp-env but don't wait for REST API to be advertised #61627
Comments
Side note: I think the test runner shouldn't assume that the consumer will be using |
I think current behaviour would be to start wp-env regardless of Edit: that's wrong - sorry 😄 |
Are you referring to this line?
Right now, with the
Hmm maybe we could use Something like that: const baseUrl = process.env.WP_BASE_URL || 'http://localhost:8889';
// ...
webServer: {
url: `${baseUrl}/?rest_route=/wp/v2`
command: 'npm run wp-env start',
port: 8889,
timeout: 120_000, // 120 seconds.
reuseExistingServer: true,
},
That doesn't sound like great DX to me. |
@swissspidy, Previously, using the Docker or @GraemeF, sorry, I went off-topic. I agree it makes sense to wait for REST API. Screenshot |
We were trying to run some e2e tests on our own blocks in a similar way to gutenberg and noticed this. To fix we:
I'm not sure how |
I think
FWIW |
You're right -
Unfortunately not - we found that WordPress will initially respond without the |
👋 I've added a simple retry mechanism for the API discovery using |
Description
Playwright is configured to start wp-env if not already running, but when it does the REST API likely isn't ready in time for the
globalSetup
function to use it. To get around that, the GitHub workflow starts wp-env ahead of the tests in the hope that it's started by the time theglobalSetup
function tries to use it.Step-by-step reproduction instructions
In the gutenberg repo, make sure
wp-env
is not already running, then run the e2e tests:Expected behaviour
Playwright should wait for all required services to be available before running tests, or should not be configured to start wp-env at all, to clarify that this needs to be done ahead of time.
Actual behaviour
Playwright starts wp-env, waits for the WordPress port to be open, and then attempts to discover the location of the REST API. The REST API isn't immediately advertised via the
link
header, so discovery fails and the tests are not run.The text was updated successfully, but these errors were encountered: