-
Notifications
You must be signed in to change notification settings - Fork 309
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
[Bug]: Could not parse CSS stylesheet #2194
Comments
This bug is also reported for primeng team: primefaces/primeng#14085 |
Bump. Have been seeing this in my workspace and trying to get to the bottom of it |
The Problem seems to be the CSS parser "cssom" that jsdom uses. I does not support NV/CSSOM#109 (comment) Here is one of the pieces of code that fails for me: This is a copy of the comment on the PrimeNG issue: primefaces/primeng#14085 (comment) |
I wonder if it's possible to parse CSS before JSDOM processes it. That might solve the issue |
We had the same problem in our Angular application and the source of it was as described primefaces/primeng#14085 (comment). Our solution after trying out unsuccessfully vitetest integrating over analogjs as a replacement for jest, as suggested here, we resolved our issue with the following solution: npm install --save-dev happy-dom For alternative configurations one can checkout the readme here. This is a copy of the comment on the PrimeNG issue: primefaces/primeng#14085 (comment) |
I was having the same issue using Primereact + Nextjs and this solution works, thank you! |
Switching to an alternative test environment (happy-dom, in this case as suggested above) solved this for me. Test execution speed seems similar, nothing has broken. Only thing I'd like now is to make jsdom a peer dependency rather than a dependency of this package so we can choose to opt out of it. |
put this in let consoleSpy: jest.SpyInstance;
beforeAll(() => {
consoleSpy = jest.spyOn(global.console, 'error').mockImplementation((message) => {
if (!message?.message?.includes('Could not parse CSS stylesheet')) {
global.console.warn(message);
}
})
});
afterAll(() => consoleSpy.mockRestore()); |
it's not a fix, you're just hiding the problem. |
Well that’s what I wanted as I couldn’t find the one which will solve the issue easily |
Do we have solution for this problem ? |
@sshelake25 one of workarounds is this one #2194 (comment) |
Version
13.1.4
Steps to reproduce
Steps which I made to prepare repo:
Expected behavior
Should work without any errors
Actual behavior
Error is shown in console:
Additional context
In one of v16 releases PrimeNg has used @layer at-rule inside their css stylesheets. It looks like jsdom for some reason cannot parse css, which contains @layer {} at-rule - I found this issue reported: jsdom/jsdom#2177.
Adding some trick to stub console.error to not show this error works, since it is not preventing tests from pass.
Environment
The text was updated successfully, but these errors were encountered: