2 Problems with setup() method in the RequestUtils class of @wordpress/e2e-test-utils-playwright #53277
Labels
Needs Testing
Needs further testing to be confirmed.
[Package] E2E Test Utils
/packages/e2e-test-utils
[Type] Bug
An existing feature does not function as intended
Description
While I know
@wordpress/e2e-test-utils-playwright
is under active development, when working with the package it was expected that I could useRequestUtils.setup()
to make WP REST API requests; however, I am experiencing two different issues when trying to use this setup method:Issue 1: Unable to pass custom baseURL
I am unable to change the
baseURL
by passing a custom url within theRequestUtils.setup( { baseUrl: 'http://example.com' } )
. This could be expected behavior, because I can pass theWP_BASE_URL
as an environment variable (i.e.WP_BASE_URL=http://example.com npx playwright test
), but it seems that this parameter should be overwritten within thesetup()
method.You can see an example of this problem within
custom-baseURL
branch of this repo: https://github.com/kopepasah/wp-playwright-request-utils-test/tree/custom-baseURLIssue 2: Multiple requests causes random failures
When running requests using
RequestUtils.setup()
andnpx playwright test
, I cannot make multiple requests, as one of the two requests will always fail (which one is random). You can see and an example of this problem in themultiple-requests
branch of this repo: https://github.com/kopepasah/wp-playwright-request-utils-test/tree/multiple-requestsNow, I can see that the Gutenberg e2e tests are setting up their own
requestContext
in Playwright, but it seems odd that the RequestUtils class does not perform that setup automatically, as it is expected thatRequestUtils.setup()
will handle this here. I have not tried the newContext in Playwright (like the Gutenberg e2e tests) way yet, because I was hoping this setup will be handled by the RequestUtils class.Thanks for taking a look, and all help is appreciated!
Step-by-step reproduction instructions
Please visit this repo for reproducing these issues: https://github.com/kopepasah/wp-playwright-request-utils-test/
This repo is a blank plugin, which installs the lates WordPress using
@wordpress/env
. In addition, it installs and sets up@playwright/test
and@wordpress/e2e-test-utils-playwright
for testing.Screenshots, screen recording, code snippet
No response
Environment info
Regarding this issue, the WordPress and Gutenberg versions are not relevant, and all other code is default WordPress.
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: