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

XPath implementation #1125

Open
artursvonda opened this issue Oct 9, 2023 · 2 comments
Open

XPath implementation #1125

artursvonda opened this issue Oct 9, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@artursvonda
Copy link
Contributor

Is your feature request related to a problem? Please describe.
While playing around with adding happy-dom to test suite for @testing-library/user-event, I noticed that a ton of errors where coming from the fact that happy-dom lacks XPath functionality.

I couldn't find any discussion about it here, decided to start one. I also recognise this might not align with package's goals.

Describe the solution you'd like
In order to facilitate better re-usability and this feature (XPath) being a standard, I think it would makes sense to create a separate package specifically for xpath implementation that could be re-used across projects. As a starting point we could take JSDom's implementation and add types. Eventually JSDOM could reuse same implementation should they choose to.

Describe alternatives you've considered
Could do this without involving happy-dom at all and just create the package and import it in both @testing-library/user-event and any projects that use happy-dom. But that's less than ideal.

Additional context
https://developer.mozilla.org/en-US/docs/Web/XPath

@artursvonda artursvonda added the enhancement New feature or request label Oct 9, 2023
@capricorn86
Copy link
Owner

capricorn86 commented Oct 9, 2023

Thank you for reporting @artursvonda! 🙂

Most implementations in Happy DOM follow standards, but as some functionality rely on internal logic inside the Happy DOM environment I have found that it is usually easier to just implement it inside Happy DOM to start with.

It seems like @testing-library@user-event is using the method document.evaluate(). This is probably the method that we need to implement to add support for it.

Do you have some examples of logic that you use with @testing-library/user-event that is currently failing? It can be a good start to write integration tests for it.

@artursvonda
Copy link
Contributor Author

Hey, @capricorn86! Sorry for being quiet for so long.

I set up separate pipeline for user-event to run against happy-dom: https://github.com/artursvonda/user-event/actions/runs/6651168387/job/18072670018?pr=1. I will ping maintainers of user-event to see if we can officially add this to their build pipeline so we can continuously monitor this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants