Why the heck isn't there an equivalent to Playwright's locator? #31957
Replies: 3 comments
-
Storybook uses Testing Library DOM because it's executable in every browser, not just Playwright's special browser. You can read about why TL doesn't support CSS queries here. https://testing-library.com/docs/dom-testing-library/intro/ We are considering adding the locator API though. Request noted! |
Beta Was this translation helpful? Give feedback.
-
You can query elements using css selectors in Storybook by using
Although, as people mentioned above, relying on CSS selectors is fragile. Testing library has a great read on Query Priorities explaining it in more details. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to use play functions for testing, but the lack of ability to search by css selector is very frustrating. In Playwright, I can do something like
page.locator("label[data-attribute='test']")
, and it would find the component without issue. Without this, there's no way to do serious testing. It's 2025, play functions are built on Playwright, there's no reason that this feature is omitted.Beta Was this translation helpful? Give feedback.
All reactions