-
Notifications
You must be signed in to change notification settings - Fork 466
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
[attribute selector]:has(+ el) pseudo-class selector with emotionStyled reported as syntax error #1317
Comments
Hi @gavrielrh did you manage to find a workaround for this? I've tried migrating to Happy DOM, which seems to solve this problem, but introduces other issues. |
This is not a jest-dom issue. jest-dom is in charge of the jest custom matchers. That is, the things that come after The code you show is not even using jest-dom features. It is, however, using I'm moving this issue to that repo instead. |
@gavrielrh FYI, I found that anything with an escaped colon in it, followed by |
AFAIU, this is related to your testing environment. |
@testing-library/jest-dom
version: 6.2.0node
version: 20.11.0jest
version: 29.7.0yarn
version: 1.22.19Relevant code or config:
What you did:
Wrote a test for a component that uses a specific CSS selector in emotionStyled.
The CSS is applying properly to the component outside of the test.
Ran the test.
What happened:
Reproduction:
Codesandbox: https://codesandbox.io/p/devbox/eager-leaf-fk2n4y?file=%2Fsrc%2Findex.test.tsx%3A11%2C1
Problem description:
It appears that an underlying library (nwsapi?) used by @testing-library fails to parse the :has() pseudo-class selector if it is prefixed with an attribute selector. This bubbles up as a syntax error when running the test.
The syntax error is not very helpful:
and the error itself means it is impossible to test components using emotion styled that rely on this selector.
Suggested solution:
Assuming the issue is with nwsapi, updating how it parses the :has() selector to account for the possibility of a attribute selector prefix, would fix this.
I don't know enough about testing-library/dom -> jsdom -> nwsapi to feel confident that this is the correct solution though.
The text was updated successfully, but these errors were encountered: