Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature - update a specific part of a snapshot #4015

Closed
nellobrunelli opened this issue Jul 12, 2017 · 2 comments
Closed

feature - update a specific part of a snapshot #4015

nellobrunelli opened this issue Jul 12, 2017 · 2 comments

Comments

@nellobrunelli
Copy link

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

@thymikee
Copy link
Collaborator

Thanks, we're good, busy changing names and stuff 😉 cc: @cpojer @aaronabramov

There's a work in progress PR handling this, but it looks like it won't ship too early: #3831
We also track the issue here: #1798
Closing as a duplicate.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants