Skip to content
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

(webdriverio): add throttleCPU and throttleNetwork commands #11548

Conversation

erwinheitzman
Copy link
Member

@erwinheitzman erwinheitzman commented Oct 30, 2023

Proposed changes

  • Added a throttleNetwork and throttleCPU command, after which the throttle command has become an alias for throttleNetwork.
  • Updated the debugging docs to explain the different causes of flakiness and how they can be debugged (using the throttleNetwork and throttleCPU command)

This allows our users to easily throttle both and debug flaky tests.
We can remove the throttle command itself in v9.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Reviewers: @webdriverio/project-committers

@erwinheitzman erwinheitzman marked this pull request as ready for review October 30, 2023 10:05
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Some minor comments but overall looks good.

@erwinheitzman
Copy link
Member Author

Thanks @christian-bromann I have resolved your feedback 👍

@erwinheitzman
Copy link
Member Author

Is there a way to improve the failing test?

I don't see why we check the amount of browser commands

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

I would love to see a better deprecation system because this message gets lost in the logs and I wonder if we can better amplify it in the stdout. However this should not block this PR to get merged.

LGTM 👍

@erwinheitzman
Copy link
Member Author

Can this be merged with the failing tests?

@christian-bromann
Copy link
Member

I think we should fix the one that is failing. I can take a look when I have time.

@erwinheitzman
Copy link
Member Author

I think we should fix the one that is failing. I can take a look when I have time.

These are the same tests that are failing for #11542 and I honestly have no idea why it's failing in either of these PR's 😮
Any pointers or help with this is greatly appreciated ❤️

@christian-bromann
Copy link
Member

christian-bromann commented Nov 3, 2023

These are the same tests that are failing for #11542

Not quite, in this PR this test is failing:

 FAIL  packages/webdriverio/tests/commands/browser.test.ts > browser commands list and strategies
AssertionError: expected [ 'puppeteer', '$$', '$', …(36) ] to deeply equal [ 'puppeteer', '$$', '$', …(37) ]

in #11542 the following tests are failing:

FAIL  packages/wdio-utils/tests/node/index.test.ts > startWebDriver > should start firefox driver
AssertionError: expected "spy" to be called with arguments: [ { port: 1234, foo: 'bar', …(1) } ]

 FAIL  packages/wdio-utils/tests/node/index.test.ts > startWebDriver > should start no driver or download geckodriver if binaries are defined
AssertionError: expected "spy" to be called with arguments: [ { cacheDir: Any{ …(3) }, …(2) } ]

For latter you have to adjust the assertions since you now set different arguments when starting a Chromedriver session. For this PR it seems like the throttle command is not attached to the scope properly.

@@ -29,7 +29,8 @@ export * from './browser/setCookies.js'
export * from './browser/setTimeout.js'
export * from './browser/setWindowSize.js'
export * from './browser/switchWindow.js'
export * from './browser/throttle.js'
Copy link
Member

Choose a reason for hiding this comment

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

By removing this export, the command is not attached to the browser scope anymore which would cause a breaking change

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Resolve build issues.

packages/webdriverio/src/commands/browser.ts Show resolved Hide resolved
packages/webdriverio/src/commands/browser/throttle.ts Outdated Show resolved Hide resolved
website/docs/Debugging.md Outdated Show resolved Hide resolved
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

I will go ahead and merge this and gonna fix remaining test issues in main.

Thanks a lot, this is awesome 👍

@christian-bromann christian-bromann added the PR: New Feature 🚀 PRs that contain new features label Nov 8, 2023
@christian-bromann christian-bromann merged commit da33985 into webdriverio:main Nov 8, 2023
4 of 8 checks passed
@erwinheitzman erwinheitzman deleted the add-throttleCPU-and-throttleNetwork-command branch December 6, 2023 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: New Feature 🚀 PRs that contain new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants