styled-components / jest-styled-components

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

Feature Request: Add option to serializer to fully strip SC classes #398

Open Jasperrr91 opened 2 years ago

Jasperrr91 commented 2 years ago

Hi there,

The provided serializer currently allows us to define two options:

For the projects in our organisation, we would like to be able to fully strip the classNames in snapshots/storyshots. The c0 c1 don't have any added value to us and result into bloating our merge requests with meaningless changes; at worst causing unnecessary merge conflicts.

We could provide a classNameFormatter that returns null, this however leaves us with 1 whitespace per styled component class. I would like to open a PR to add a third option stripClasses which if set to true will call stripUnreferencedClassNames instead of replaceClassNames/replaceHashes. Nothing more nothing less.

For now we're using a custom package which is basically a dumbed down version of the jest-styled-components/serializerwith this feature added; but we would prefer to stick to the official tooling. Hence this feature request.