styled-components / jest-styled-components

🔧 💅 Jest utilities for Styled Components
MIT License
1.59k stars 145 forks source link

I'd like to remove styles but keep the incremented classNames #357

Closed skvale closed 3 years ago

skvale commented 3 years ago

In some cases I want to capture snapshots without the styles. I just want the rendered DOM.

I'm wondering if you'd be interested in supporting this?

I can accomplish what I want with this diff

// line 127 of src/styleSheetSerializer.js
- const code = print(val);

- let result = `${style}${style ? '\n\n' : ''}${code}`;
+ let result = print(val);

But it'd be nice to have some way to configure jest-styled-components to do this per test.

I had something like this in mind

    let result;
    if (global.stripStyles) {
      result = code;
    } else {
      result = `${style}${style ? '\n\n' : ''}${code}`;
    }
skvale commented 3 years ago

Perhaps https://github.com/cssinjs/jss-snapshot-serializer would work for this