[wp-trac] [WordPress Trac] #54420: Tests: Mock REST API remote requests
WordPress Trac
noreply at wordpress.org
Wed Nov 17 19:34:11 UTC 2021
#54420: Tests: Mock REST API remote requests
------------------------------+-----------------------------
Reporter: hellofromTonya | Owner: hellofromTonya
Type: task (blessed) | Status: reopened
Priority: normal | Milestone: 6.0
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: rest-api
------------------------------+-----------------------------
Comment (by SergeyBiryukov):
Replying to [comment:17 hellofromTonya]:
> Tests in `Tests_Admin_IncludesTheme::test_get_theme_featured_list_api()`
timed out in this [https://github.com/WordPress/wordpress-
develop/runs/4222801461?check_suite_focus=true CI Job], i.e. `Run external
HTTP tests`. Noting it here as another test for mocking the HTTP remote
request.
This was added in [39906] / #28121 to make sure that the list of theme
features pulled from the WordPress.org API returns the expected data
structure. Wouldn't mocking this response defeat the purpose of the test?
This raises an interesting point: when mocking the response, we should
consider the intent of the test, and whether it was specifically written
to protect from unexpected changes in the WordPress.org API response.
This may very well also apply to the tests changed in [52137] and [52138].
Note that the latter previously had a comment: `// This will hit the live
API`. Seems worth investigating whether that live request was intentional.
Perhaps a better option would be to add them to the `external-http` group
and ignore any timeouts? See the
`WP_UnitTestCase_Base::skipTestOnTimeout()` method and the tests using it
for example.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54420#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list