Git Product home page Git Product logo

Comments (7)

runk avatar runk commented on July 26, 2024

Would be awesome to have this feature. 💯

from enzyme-to-json.

JonathanTR avatar JonathanTR commented on July 26, 2024

What would it look to configure this? Maybe something like?:

import serializer from 'enzyme-to-json/serializer';
import Foo        from './Foo'

const compactSerializer = serializer.withExceptions([<ul />, <Foo />]);
expect.addSnapshotSerializer(compactSerializer);

from enzyme-to-json.

adriantoine avatar adriantoine commented on July 26, 2024

Hi!

Thanks for your suggestions, would you mind giving more details about that? I don't think I understand, you want a snapshot with only elements and inner texts?

enzyme-to-json is only converting Enzyme wrappers to a JSON format that is compatible with Jest snapshot testing. Isn't that something you want to be implemented in Jest so that it is available for people only using react-test-renderer?

from enzyme-to-json.

JonathanTR avatar JonathanTR commented on July 26, 2024

Ah, I'm realizing that what I wanted was actually quite different from OP, as I had read their post pretty quickly. What I was thinking was something more along the lines of being able to collapse certain elements within a snapshot.

So instead of having:

<Button
  color="blue"
>
  <button
    className="button blue"
  >
  </button>
</Button>

I could configure my serializer to just return something like:

<Button
  color="blue"
>
  { [children] }
</Button>

This would be awesome for cleaning up snapshots, especially in cases where there's lots of HOC's wrapped up in an implementation. Being able to configure whether I wanted inline props or not would be even more cool, so I could end up with a beautiful snapshot like:

<Button color="blue">
  { [children] }
</Button>

from enzyme-to-json.

adriantoine avatar adriantoine commented on July 26, 2024

I'm working on a map functionality (see #48) which would give much more control on the output. It will be released with v3.0.0.

I'm not sure about the details of the implementation but I'll give more details in #67 as soon as I can.

Thanks for your suggestions!

from enzyme-to-json.

adriantoine avatar adriantoine commented on July 26, 2024

@JonathanTR @dzhytomyrsky @runk I just added a comment to #67 about this new mapping functionality, can you tell me if it solves your issue?

Thanks!

from enzyme-to-json.

adriantoine avatar adriantoine commented on July 26, 2024

v3.0.0 has been released 🎉, the map functionality should cover this use case, if not, please comment on this issue!

from enzyme-to-json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.