jest-styled-components icon indicating copy to clipboard operation
jest-styled-components copied to clipboard

Tests break when testing with Jest 27

Open pyymenta opened this issue 3 years ago • 3 comments

Hi guys,

I'm trying to update Jest in a NextJS project.

Using the version 26.6.3, the tests run fine.

image

Then when I update Jest up to 27.0.0 I get the following error:

image

I've created a project that reproduces the error:

The test will fail in:

https://www.github.com/pyymenta/jest-27-styled-components

The test will pass in:

https://github.com/pyymenta/jest-27-styled-components/tree/jest-26.6.3

I noticed that Jest 27 had some breaking changes, I'm investigating it but without success yet. Any ideas?

pyymenta avatar Jun 18 '21 21:06 pyymenta

The tests also stopped working for me. Any solution?

UltiRequiem avatar Aug 11 '21 03:08 UltiRequiem

On my project, our tests broke with this same error. The problem was ocurring because styled-components was installed on the root of my node_modules and on the node_modules inside jest-styled-components. I solved it by adding this to my package.json and doing a clean install (rm -r node_modules && yarn install):

"resolutions": {
    "styled-components": "5.3.1",
 }

ThiagoNP avatar Sep 22 '21 22:09 ThiagoNP

Hey guys,

I fixed the problem adding the following entry in my jest configuration in package.json file:

image

Branch: https://github.com/pyymenta/jest-27-styled-components/blob/jest-27-fixed/package.json#L24

image

pyymenta avatar Sep 27 '21 12:09 pyymenta