Re: [csswg-drafts] Allow triggering of native pseudo-classes for development purposes (#12202)

Another similar use case, is when writing UI tests executed in the browser using JS APIs. Usually this is done with the [Testing Library suite](https://testing-library.com/), but there are other ways of course. Users will use [`@testing-library/user-event`](https://testing-library.com/docs/user-event/intro) to simulate interactions - such as click and type - directly in the browser. Over the years I've probably had 30+ conversations with users that expected [`userEvent.hover()`](https://testing-library.com/docs/user-event/convenience#hover) to enable the hover style on the element, having to explain them that it doesn't because there is no browser API that would allow that to work.

A few years ago this wasn't a big problem because testing was done in a simulated JSDOM environment, but today we're seeing more and more of these tests running directly in an actual browser instead, which is a lot more useful.

I'd personally expect the use cases for this to be primarily based around JS flows, but a CSS API like proposed above would be pretty easy to use in JS too.

I think a lot of users would benefit from this being solved, let me know if there's any way I can help making this happen.

(Full disclosure: I'm a core maintainer of Storybook, where this issue comes up a lot)

-- 
GitHub Notification of comment by JReinhold
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12202#issuecomment-2886000730 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 16 May 2025 08:20:04 UTC