So I\'m writing a test for my Item component and I tried to render the ItemCard component and then use that wrapper to create a snapshot but it returns an empty
I faced the same issue and resolved using serializer https://github.com/adriantoine/enzyme-to-json.
npm install --save-dev enzyme-to-json
Once installed the enzyme-to-json we can use something like below
import React, {Component} from 'react';
import {shallow} from 'enzyme';
import toJson from 'enzyme-to-json';
it('renders correctly', () => {
const wrapper = shallow(
Hello World!
,
);
expect(toJson(wrapper)).toMatchSnapshot();
});
The same can be resolved using shallow().debug() but prefer to use the above method.