{"repo":"adriantoine/enzyme-to-json","free":true,"listed":false,"github":"https://github.com/adriantoine/enzyme-to-json","clone":"git clone https://github.com/adriantoine/enzyme-to-json.git","description":"Snapshot test your Enzyme wrappers","language":"JavaScript","stars":940,"topics":["react","enzyme","snapshot-testing","enzyme-helper","jest","jest-serializer","unit-testing","serializer","enzyme-wrappers"],"license":"MIT","category":"ui-components","readme_excerpt":"enzyme-to-json Convert Enzyme wrappers to a format compatible with Jest snapshot testing. Install Usage The serializer is the recommended way to use enzyme-to-json , the installation and usage of it is very easy and allows you to write clean and simple snapshot tests. In order to use the serializer, just add this line to your Jest configuration: Example For most projects, that is all you need to start using snapshot tests on Enzyme wrappers. The rest of this readme is only showing advanced usages of this library. In case you are still confused, here is a minimal example project demonstrating this configuration. Advanced usage Serializer in unit tests You can add the serializer for only one Jest test file by adding these lines at the beginning of your Jest unit test file: You can also add the serializer for all tests using the setupFilesAfterEnv configuration option from Jest. Helper At the beginning, enzyme-to-json was just a helper because serializers weren't supported by Jest. Even though it is now recommended to use the serializer to keep your tests simple, you can still use the helper as it gives you access to the option objects. The helper is just a function you can import from enzyme-to-json and just pass your Enzyme wrapper as the first parameter and snapshot test the returned value, you'll get the same results as if you used the serializer. Note that you don't have to disable the serializer if you had configured it for the rest of your project. Here is a usage example","default_branch":null,"files":null,"tree":[],"storefront":"/r/adriantoine","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/adriantoine/enzyme-to-json/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}