Skip to content

Instantly share code, notes, and snippets.

@Ranguro
Created February 12, 2019 17:31
Show Gist options
  • Save Ranguro/a14b6b8e6868ff508b80f29df8a99971 to your computer and use it in GitHub Desktop.
Save Ranguro/a14b6b8e6868ff508b80f29df8a99971 to your computer and use it in GitHub Desktop.
/* Test Code */
import React from 'react';
import { shallow } from 'enzyme';
import { createSerializer } from 'enzyme-to-json';
// eslint-disable-next-line
import DummyComponent from '../component-dir/DummyComponent';
// eslint-disable-next-line
// Uncomment this line and it removes the warning regarding to enzyme-adapter-react-15
//expect.addSnapshotSerializer(createSerializer({ mode: 'deep' }));
function doShallow() {
const wrapper = shallow(<DummyComponent />);
return { wrapper };
}
describe('<DummyComponent/> Component', () => {
it('Should compile', () => {
const { wrapper } = doShallow();
expect(wrapper).toMatchSnapshot();
console.log('Wrapper debug');
console.log(wrapper.debug());
});
});
/* Dummy Component Code */
import React from 'react';
const DummyComponent = () => {
const TestComponent = (
<div id={'someId'}>
Test component
</div>
);
return (
<article className='some-classname'>
{TestComponent}
</article>
);
};
export default DummyComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment