Skip to content

Playwright e2e utils: add new emulateNetworkConditions helper #69865

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

Merged
merged 3 commits into from
Apr 9, 2025

Conversation

swissspidy
Copy link
Member

What?

Adds a new PageUtils.emulateNetworkConditions() helper to emulate network conditions such as Slow 3G, Fast 4G or Broadband.

Why?

For performance tests in Gutenberg and core it would be nice if we'd be able to not only simulate mobile viewports, but also mobile network conditions. And even for desktop we want to use some realistic conditions that are aligned with what other tools such as Lighthouse use.

How?

Testing Instructions

In a test you should be able to use the pageUtils fixture and then do await pageUtils.emulateNetworkConditions( 'Fast 4G' );.

Testing Instructions for Keyboard

N/A

Screenshots or screencast

N/A

Before After

@swissspidy swissspidy added [Type] Enhancement A suggestion for improvement. [Tool] E2E Test Utils /packages/e2e-test-utils labels Apr 9, 2025
@swissspidy swissspidy requested a review from kevin940726 as a code owner April 9, 2025 09:47
Copy link

github-actions bot commented Apr 9, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm not familiar with Playwright.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swissspidy Looks great!

Will you open separate PRs to actually use this in the Gutenberg and Core Performance tests?

@swissspidy
Copy link
Member Author

Yes, once this is released on npm

…ork-conditions.ts

Co-authored-by: Weston Ruter <westonruter@google.com>
@swissspidy swissspidy merged commit a4f9a83 into trunk Apr 9, 2025
59 checks passed
@swissspidy swissspidy deleted the add/pw-emulate-network branch April 9, 2025 19:58
@github-actions github-actions bot added this to the Gutenberg 20.7 milestone Apr 9, 2025
@bph bph added the [Type] Code Quality Issues or PRs that relate to code quality label Apr 13, 2025
@swissspidy swissspidy removed the [Type] Code Quality Issues or PRs that relate to code quality label Apr 13, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…Press#69865)

Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] E2E Test Utils /packages/e2e-test-utils [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants