Comments (11)
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
npm install --save-dev @happy-dom/jest-environment
And configuring the jest.config.ts with the following property:
{ "testEnvironment": "@happy-dom/jest-environment" }
For alternative configurations one can checkout the readme here.
This is a copy of the comment on the PrimeNG issue: primefaces/primeng#14085 (comment)
from jest-preset-angular.
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 npm install --save-dev @happy-dom/jest-environment And configuring the jest.config.ts with the following property: { "testEnvironment": "@happy-dom/jest-environment" }
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!
from jest-preset-angular.
put this in setup-jest.ts
This should fix the issue
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());
from jest-preset-angular.
This bug is also reported for primeng team: primefaces/primeng#14085
from jest-preset-angular.
Bump. Have been seeing this in my workspace and trying to get to the bottom of it
from jest-preset-angular.
The Problem seems to be the CSS parser "cssom" that jsdom uses. I does not support @layer
.
NV/CSSOM#109 (comment)
jsdom/jsdom#2026
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)
from jest-preset-angular.
I wonder if it's possible to parse CSS before JSDOM processes it. That might solve the issue
from jest-preset-angular.
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.
from jest-preset-angular.
put this in
setup-jest.ts
This should fix the issuelet 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.
from jest-preset-angular.
put this in
setup-jest.ts
This should fix the issuelet 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
I have chose this approach as this is minimal and I don’t wanted my console to be flooded with these error msg
from jest-preset-angular.
from jest-preset-angular.
Related Issues (20)
- [Bug]: jest-preset-angular 13.1.4 - `spyOn` no longer works for functions imported with `import * as` HOT 1
- [Feature]: Angular 17 support HOT 5
- [Bug]: Cannot read properties of undefined (reading 'each') of zone-testing HOT 3
- [Bug]: Drop support Angular versions
- [Bug]: Input signals in components cause tests to error out (Angular v17.1.0) HOT 8
- [Bug]: It is not work After config useESM: true HOT 3
- [Feature]: Support viewChild query from 17.2 HOT 4
- [Feature]: Support for contentChild signal functions HOT 1
- Unexpected tokenyntaxError: Unexpected token '??=' at wrapSafe (internal/modules/cjs/loader.js:1001:16) HOT 6
- [Bug]: Import in component is undefined under test HOT 2
- [Bug]: jest-global-mocks should set the value of `CSS` to undefined and not null
- [Feature]: Package Updation HOT 1
- [Bug]: input.required signals cannot be set in TestBed HOT 5
- [Feature]: Support `outputFromObservable` interop function for `output`
- [Bug]: Generics throw error on jit_transform.js
- How to specify custom tsconfig file? HOT 7
- [Bug]: ReferenceError: TextEncoder is not defined HOT 1
- Is jest compatible with angular 18 HOT 1
- [Bug]: Declaration of TestComponent with signal input breaks jest.mock HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-preset-angular.