Skip to content

Conversation

@julienw
Copy link
Contributor

@julienw julienw commented Nov 4, 2025

Indeed webdriver.io has a different behavior when the argument is not undefined.

Fixes #8931

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@julienw julienw force-pushed the click-take-undefined branch from 0250506 to 4b82d43 Compare November 4, 2025 15:33
context,
selector,
options = {},
options,
Copy link
Member

Choose a reason for hiding this comment

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

Did you check what is passed here when = {} is removed? I think we always normalize it in the browser/*/locators/index.ts

Maybe a better test could catch that 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah good question, I'll double check at least by adding logs :)

I'm not sure how to do a good test, as they should essentially do the same thing in the end ... except with more work (possibly taking longer especially).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe I could try to mock the call to see what is really called...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're right of course:

public click(options: UserEventClickOptions = {}): Promise<void> {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Playwright defaults to {} too, and the preview one doesn't take any option, so I guess we can remove the default everywhere.

https://github.com/microsoft/playwright/blob/e7bff526433b6dcb02801763ab5b1c6407902d47/packages/playwright-core/src/client/locator.ts#L108

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://bugzilla.mozilla.org/show_bug.cgi?id=1456642 turns out there's a bug open in Firefox, it looks like it's actively worked on these days.

Given there's an easy workaround (passing {} as a parameter to click), I'll leave it up to you to decide if you want to merge this.

Copy link
Member

Choose a reason for hiding this comment

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

I think if we can add a documentation notice to the click event, it's fine to merge. The impact should not be big

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed some documentation, tell me if that looks like what you expected.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, looks good to me, just make sure eslint doesn't fail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh no, should be fixed now :-)

@julienw
Copy link
Contributor Author

julienw commented Nov 5, 2025

FWIW this is the webdriver.io bug I was running into because of that: webdriverio/webdriverio#14840

Comment on lines 32 to 35

onClick.mockClear()
await userEvent.click(button, { button: 'right' })
expect(onClick).toHaveBeenCalled()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you give me some hint about how to run this test only? I couldn't find it :/

Copy link
Member

Choose a reason for hiding this comment

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

in test/core:

PROVIDER=webdriverio pnpm test-fixtures userEvent --run -t "correctly clicks a button"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess you meant test/browser :)

I see my new test wasn't passing either, but I don't see that in the CI, are they running there?

Now I can fix all of that, thanks!

@julienw julienw force-pushed the click-take-undefined branch from 4b82d43 to c11b560 Compare November 5, 2025 12:58
@netlify
Copy link

netlify bot commented Nov 5, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1342ef6
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/690baf634caff9000879584e
😎 Deploy Preview https://deploy-preview-8937--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@julienw
Copy link
Contributor Author

julienw commented Nov 5, 2025

It's not clear to me why the tests are failing :/ I tested locally the individual files, they pass for me, but they don't seem to pass when testing the runner...

Though I'm on Linux, Linux passes too in CI, just not Windows and MacOS, so there might be something different there?

@julienw julienw force-pushed the click-take-undefined branch from c11b560 to 3787d5a Compare November 5, 2025 14:33
@julienw
Copy link
Contributor Author

julienw commented Nov 5, 2025

I reverted the changes on playwright because this wasn't related to this issue, I just wanted to make things consistent and I thought this would change nothing. But maybe I misread the playwright code. Let's see if this fixes the tests.

Update: this didn't fix the test.

…driver command should also have no argument

Indeed webdriver.io has a different behavior when the argument is not
undefined.

Fixes vitest-dev#8931
@julienw julienw force-pushed the click-take-undefined branch from 3787d5a to 7e89e16 Compare November 5, 2025 15:03
@julienw
Copy link
Contributor Author

julienw commented Nov 5, 2025

By preventing the context menu from appearing when clicking right, I fixed the tests, to make new failures appear, which make more sense. I wonder if that might be a bug in Firefox...

It's still pretty weird that only macos fails, and not linux. (I don't know for windows yet) update: Ah of course, browser tests are not run on Ubuntu.

@julienw julienw force-pushed the click-take-undefined branch from 2515cb7 to 1342ef6 Compare November 5, 2025 20:11
@sheremet-va sheremet-va merged commit 069e6db into vitest-dev:main Nov 6, 2025
13 of 14 checks passed
@sheremet-va
Copy link
Member

Thank you!

@julienw
Copy link
Contributor Author

julienw commented Nov 6, 2025

Thanks!

@julienw
Copy link
Contributor Author

julienw commented Nov 6, 2025

Is there a changelog to update about this, or will you add it to the release notes ?

@sheremet-va
Copy link
Member

Is there a changelog to update about this, or will you add it to the release notes ?

release notes are generated based on the squashed commit message

@julienw
Copy link
Contributor Author

julienw commented Nov 6, 2025

Okay, just want to make sure the folks know what to do in case they see failures because of that.

@julienw
Copy link
Contributor Author

julienw commented Nov 7, 2025

So this change actually avoided the bug I mentioned earlier webdriverio/webdriverio#14840 in Firefox... but now I get a new webdriver bug in Chrome, related to a web component wrapping a button element. Nothing related to vitest IMO, but I wanted to mention it in case other folks got the issue.

@julienw
Copy link
Contributor Author

julienw commented Nov 10, 2025

Not related to vitest directly, but mentioning it in case this can be useful to other folks.
Using ElementClick instead of the actions like previously hits this Chrome issue sometimes: https://groups.google.com/g/chromedriver-users/c/9oxCEdNUdYg/m/7A4DIbbnAQAJ :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webdrivers's click should be called with undefined as the default value

2 participants