styled-components / jest-styled-components

🔧 💅 Jest utilities for Styled Components
MIT License
1.58k stars 144 forks source link

Compatibility Issue with `jest-styled-components` and Storybook's `test-runner` #443

Open naporin0624 opened 6 months ago

naporin0624 commented 6 months ago

Issue Overview.

I am experiencing a problem with jest-styled-components not working as expected when using test-runner in Storybook. The problem seems to be caused by the way test-runner handles rendering.

  1. test-runner --eject to generate test-runner-jest.config.js Add the serializer from jest-styled-components/serializer to test-runner-jest.config.js Execute snapshot by test-runner.

I get the following snapshot, but it does not show the css associated with the class.

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[\`Button Default smoke-test 1\`] = \`
<button class="sc-beySPh fvFDzo">
default button
</button>
\`;

Detailed Description.

Seeking a Solution

Are there any known solutions or workarounds for this problem?

Sample Repository

https://github.com/naporin0624/test-runner-jest-styled-components