-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Feature]: Allow browser API without browser (jsdom) #27424
Comments
One of main issues in RTL for me is a lack of visualisation. It's much harder to debug tests when instead of rendered UI you see textual DOM description, especially when the component is big. So, I want to join to @GermanJablo in this request and also want to add that if rendering of the component together with Playwright Inspector will be added to this feature, it could replace RTL for me. |
@GermanJablo, @denis-domanskii, I'm not sure you want the same thing here. @GermanJablo: You seem to be interested in using page., page.locator. APIs against JSDOM. This would be a fairly large project on our side, starting with seeding the jsdom environment, all the way to implementing all the actions programmatically. It is unlikely that we sign up for this task given our real browser focus. We would be much more interested in improving the speed of your component test execution. @denis-domanskii you seem to be interested in Playwright offering a drop-in-replacement for jsdom+rtl in a way that components are rendered and tested in the browser, so that you could see what is going on. I believe there are projects that do just that in the internet. Similarly, I don't think we'll sign up for such a resource-demanding task. |
Maybe I shouldn't have mentioned Let me narrow the scope of my suggestion to something much more modest: Make user-event bindings with the Playwright API, so that a subset of the tests that can be done in playwright can be executed in jsdom. The Playwright documentation has a cheatsheet of equivalences between the Playwright API and the RTL API.
My idea is that if you decide to run a test in jsdom, bindings could be made to This seems much more feasible since To be clear, with this reformulation of my suggestion I am not pretending that any Playwright test can run successfully in jsdom, but rather that any test that someone would do in |
Yeah, that's how I understood it. And thinking that this is feasible would be a misconception sadly. Closing as outside of scope for Playwright. |
From the documentation:
This is somewhat different from
testing library
, which allows you to test a component using an end-user API, but without having to deploy a browser in each test.While one can use testing library to test components in a simulated browser and Playwright in a real browser, it would be great if we could use the same API for both cases.
The simulated browser (jsdom) offers incredible speeds, while the real browser offers more confidence. By sharing the same API, depending on the level of trust you have in the tests, it would be trivial to change it from one environment to another. This would certainly be "the best of both worlds."
Clarification note: I understand that if one does not use Playwright fixtures, no browser is instantiated, and in theory it could be used with jsdom:
However, what I would like is to be able to test those components using APIs like page.keyboard or locator.click().
The text was updated successfully, but these errors were encountered: