Skip to content
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]: babel-plugin-styled-components is ignored/not working starting Jest 27 #406

Open
kolesker opened this issue Dec 22, 2023 · 0 comments

Comments

@kolesker
Copy link

Version

2.1.4

Steps to reproduce

  1. Clone my repo https://github.com/kolesker/ts-jest-styled-display-name-bug
  2. Choose jest-26 or jest-29 paths to test
  3. npm install
  4. npm run test

Expected behavior

In jest 26 you get as snapshot:

"<Component>
  <StyledExample>
    <div className=\\"test-issue__StyledExample-sc-yycgxi-0 cxgDRm\\" />
  </StyledExample>
</Component>"
`;

Actual behavior

In jest 29 you get as snapshot:

"<Component>
  <StyledExample>
    <div className=\\"sc-beySbM AIKwo\\" />
  </StyledExample>
</Component>"
`;

Additional context

In the migration from Jest and ts-jest 26 to 29, all of our snapshots are breaking since displayName attribute of babel-styled-components plugin is being ignored. Actually, the issue was introduced when migrating from 26 to 27, but it wasn't solved in the latest 29 version.

The problem is display names in the classes are being completely ignored, while in runtime (non-test environment) it is working OK. Also the issue is only happening after moving out from v26.

Environment

System:
    OS: macOS 13.6.2
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    npm: 9.8.1 - ~/.nvm/versions/node/v9.8.1/bin/npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant