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

Serialize style attributes as style={[object Object]} #39

Closed
dziamid opened this issue Dec 23, 2016 · 2 comments
Closed

Serialize style attributes as style={[object Object]} #39

dziamid opened this issue Dec 23, 2016 · 2 comments

Comments

@dziamid
Copy link

dziamid commented Dec 23, 2016

I'd love to ignore some attributes when a component is serialized, for the purpose of keeping its snapshot focused and not cluttered with stuff like inline styles

For example:

        <Dropzone multiple={false} accept="image/jpeg,image/png" onDrop={this.handleImageDrop}>
          <ContentAdd style={addBtnStyle} />
        </Dropzone>

Would serialize into:

<Dropzone
  accept="image/jpeg,image/png"
  multiple={false}
  onDrop={[Function]}>
  <ContentAdd
    style={
      Object {
        "color": "#1ac5c0",
        "height": 48,
        "left": "33px",
        "position": "absolute",
        "top": "33px",
        "width": 48,
      }
    } />
</Dropzone>

While i'd prefer:

<Dropzone
  accept="image/jpeg,image/png"
  multiple={false}
  onDrop={[Function]}>
  <ContentAdd 
     style={[object Object]}/> 
</Dropzone>
@dziamid dziamid changed the title Exclude attributes when serializing Serialize style attributes as style={[object Object]} Dec 23, 2016
@pedrottimark
Copy link
Contributor

@dziamid Your comments are welcome in a conversation about a potential general solution to matching a subset of attributes/properties at jestjs/jest#2202 (comment)

@adriantoine
Copy link
Owner

Hi @dziamid, that's interesting but it's not really a bug with enzyme-to-json but a bug with Jest snapshots and how pretty-format processes them! Thanks for the link @pedrottimark

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

3 participants