To fix the dynamic class generation in Next Js 15.
We have created a file style.js in the location mocks\styled-jsx\style.js & mentioned the below code:
function StyleMock() {
return null
}
// Add the static dynamic method expected by styled-jsx
StyleMock.dynamic = () => ''
export default StyleMock
& define the path under moduleNameMapper
in jest.config.js i.e.
moduleNameMapper: {
'^styled-jsx/style$': '<rootDir>/__mocks__/styled-jsx/style.js',