Skip to content

feature - update a specific part of a snapshot #4015

@nellobrunelli

Description

@nellobrunelli

Hi Jest's guys, how are you?
I'd like to use Jest snapshots for my reducers (not only for my .jsx components).

The test would be something like:

describe.only('Dialog Reducer', () => {

    test(type.DIALOG_START, () => {
        expect(
            dialog('Test one', {
                type: type.DIALOG_START
            })).toEqual({
                active: true,
                text: 'Hi mom'
            });
    });

    test(type.DIALOG_END, () => {
        expect(
            dialog('Test two', {
                type: type.DIALOG_END
            })).toMatchSnapshot();
    });
});

There are two tests inside one script. The snapshot would be something like:

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Dialog Reducers DIALOG_START`] = `
Object {
  "active": false,
  "text": 'Hi Mom',
}
`;

exports[`Dialog Reducers DIALOG_END`] = `
Object {
  "active": false,
  "text": null,
}
`;

Suppose that both tests fail I would fix them one by one. After every fix I might need to update the snapshot just for one test. But it looks like there isn't this chance because the command update the entire snapshot.

http://facebook.github.io/jest/docs/cli.html#updatesnapshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions