Snapshot with jest and enzyme is written inside the test file and not in a separate .snap file

236 Views Asked by At

I'm new to react's testing and I created a simple test for checkbox:

import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import { Checkbox } from '../../../src/components/Checkbox';

...

describe('Checkbox', () => {
    test('Simple render', () => {
        const checkbox = shallow(
            <Checkbox
                label="Label"
                value={true}
                onUpdate={null}></ReportCheckBox>
        );

        expect(toJson(checkbox)).toMatchInlineSnapshot();
    });
});

The test works as it should but it generates the snapshot inside the code itself and not in a separate file in the snapshots folder as it should. What did I do wrong?

1

There are 1 best solutions below

0
Aharon Ohayon On

After few minutes I've noticed that I was calling toMatchInlineSnapshot instead of: toMatchSnapshot