-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
"Could not parse CSS stylesheet" when running tests with jest #14085
Comments
Same issue after migrating to 16.7, the proposed solution doesn't work |
Same issue for us. |
Is this issue fixed? I am still seeing this issue. |
The Problem seems to be the CSS parser "cssom" that jsdom uses. I does not support |
facing the same issue here:
|
Same issue, any idea how to solve it? |
I'm afraid I'm also facing the same issue. Also, the workaround described in jsdom/jsdom#2177 doesn't work for me for some reason. |
I just post a message in their Discord channel, i hope someone will take it in charge ... |
I'm facing the same issue but in react |
We encountered a similar issue in our Angular project, which stemmed from the problem outlined here. After attempting to integrate vitetest with analogjs as a Jest alternative, based on the suggestion here—which didn't resolve our issue—we found success with the following steps:
For more configuration details, refer to the Happy DOM readme here. |
This literally did not change a thing for me. To be fair, I haven't had a jest.config.ts or jest.config.js in the first place until today so I'm not sure whether it's being read correctly. Here's my jest.config.js file:
I don't know whether I put testEnvironment in the right place but I'm quite sure it's correct there. The file itself is definitely loaded when I type "ng test" because if I include a syntax error, it'll show that when I run jest. But the error message is the same anyway. (The one wih |
Did you install both packages. Did you try to run jest with the setting passed over the environment to make sure that the syntax error are not from the linter or another tooling?
|
I installed both. And they are both in my package.json file under devDependencies. Not sure if it actually tries to use happy-dom but I mentioned it in the jestConfig, like I said. Running the command you just mentioned creates different errors. It seems jest can not parse any test files at all with it. My test starts with some imports and running the npx jest command from above procudes the following error:
with ^^^^^^ marking the word "import". I know Jest itself is only able to run JS code, no TypeScript because of features like import and export. This is why there are transpilers like Babel or the one Angular provides itself nowadays. This is also how I could run the tests before even trying out happy-dom. But then I get the CSS errors. (My tests are successful nonetheless but that will probably change when I start to test for something related to the CSS of an element) |
Is it Safe Using this lib ? |
Issue is still there on latest prime-ng and angular |
This issue is not going to resolve with any primeng or angular update. It is sadly a problem with the renderer used in the tests. No need to report that it is still not working on newer versions. |
Wow It's resolve my problem thanks a lot!My setup:
|
… Portlet (#30400) ### Proposed Changes * We are having several errors while running the Locales Portlet, https://gist.github.com/hmoreras/aedfd95812fbd26f901423d5e9048bcb * following this approach: primefaces/primeng#14085 (comment) ### Screenshots <img width="1490" alt="image" src="https://github.com/user-attachments/assets/d7882a5d-0a93-4308-af21-980df2289c70">
Is there a way to solve this that doesn't involve installing yet another npm package? For what it's worth, we're seeing this error with no association to primeng - I just ended up here from google. |
@brandon-clapp-sp I mean, you can remove PrimeNG and see if that fixes your problem. We didn't figure out how to reliably fix it. PrimeNG just seems to be so far off any known standard - it'll probably be better to switch to another component library, lol. I just found this and am not sure if it might help, though. |
… Portlet (#30400) ### Proposed Changes * We are having several errors while running the Locales Portlet, https://gist.github.com/hmoreras/aedfd95812fbd26f901423d5e9048bcb * following this approach: primefaces/primeng#14085 (comment) ### Screenshots <img width="1490" alt="image" src="https://github.com/user-attachments/assets/d7882a5d-0a93-4308-af21-980df2289c70">
Due to PrimeNG team's busy roadmap, this issue is available for anyone to work on. Make sure to reference this issue in your pull request. ✨ Thank you for your contribution! ✨ |
Describe the bug
After upgrading primeng 16.3.1 to 16.7.2 our jest tests fail with the following error:
These problems seem to start with version 16.4.0 and to be caused by the introduction of CSS layers.
Environment
Angular app using nx workspace
Reproducer
No response
Angular version
16.2.9
PrimeNG version
16.7.2
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.4.0
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
Jest tests should still pass.
The text was updated successfully, but these errors were encountered: