B
B
balex7772021-08-26 16:12:37
React
balex777, 2021-08-26 16:12:37

How to make Jest toMatchSnapshot of just jsx with few components?

Hello, I have Icons.tsx, it contains several components with icons (svg) how can I take a Snapshot of the entire file at once, it turns out to put only one component in create, here is an example of a test code

import React from 'react';
import { shallow } from 'enzyme';
import renderer from 'react-test-renderer';
import { BellIcon, EmailIcon, InfoIcon } from "components/Icons";

describe('Icons component', () => {

    it('renders Icons correctly', () => {

        const wrapper = renderer
            .create(<BellIcon /> )
            .toJSON();
        expect(wrapper).toMatchSnapshot();
    });
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question