GithubHelp home page GithubHelp logo

Comments (11)

CodeBast4rd avatar CodeBast4rd commented on August 16, 2024 12

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.

AnnaVidal avatar AnnaVidal commented on August 16, 2024 3

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.

abhijit-chikane avatar abhijit-chikane commented on August 16, 2024 2

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.

Trolejbus avatar Trolejbus commented on August 16, 2024 1

This bug is also reported for primeng team: primefaces/primeng#14085

from jest-preset-angular.

NathanLaing avatar NathanLaing commented on August 16, 2024

Bump. Have been seeing this in my workspace and trying to get to the bottom of it

from jest-preset-angular.

Elias-Graf avatar Elias-Graf commented on August 16, 2024

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:
image

This is a copy of the comment on the PrimeNG issue: primefaces/primeng#14085 (comment)

from jest-preset-angular.

ahnpnl avatar ahnpnl commented on August 16, 2024

I wonder if it's possible to parse CSS before JSDOM processes it. That might solve the issue

from jest-preset-angular.

pi-nathan avatar pi-nathan commented on August 16, 2024

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.

jonelleamio avatar jonelleamio commented on August 16, 2024

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());

it's not a fix, you're just hiding the problem.

from jest-preset-angular.

abhijit-chikane avatar abhijit-chikane commented on August 16, 2024

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());

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.

fabb avatar fabb commented on August 16, 2024

see jestjs/jest#15106

from jest-preset-angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.